Page MenuHomePhabricator

Refactor code for detecting preferred language & re-sorting primary links around the globe
Closed, ResolvedPublic

Description

Based on the successful A/B test, we'd like to push this update into production on the Wikipedia.org portal.

This ticket is to refactor the code from the test to make sure it's production ready.

The following is the description of what we're going to do:

This is a feature which detects the user's language and re-sorts the links around the globe on the Wikipedia portal in line with their preferred language settings. The user's preferred language will be displayed in the top left link.
If the user does not have as many language preferences as there are available links to display, fill the remainder links around the globe with the "top" links that are not in their language preferences.
If they do not have a header (lang pref file) or we cannot retrieve it, display the default experience.
If the user has a language preference that is not in English, we will take that primary preferred language and display the "The Free Encyclopedia" phrase below the Wikipedia wordmark in that preferred language.

Event Timeline

debt created this task.Apr 26 2016, 7:23 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 26 2016, 7:23 PM
debt moved this task from Needs triage to On Sprint Board on the Discovery board.May 16 2016, 6:26 PM
debt added a subscriber: JGirault.

Change 289153 had a related patch set uploaded (by Jdrewniak):
T133729 New approach to localizing top-ten links using ajax & localstorage.

https://gerrit.wikimedia.org/r/289153

debt added a comment.EditedMay 18 2016, 6:17 PM

Found some translations that we can add (based off this file: https://phab.wmfusercontent.org/file/data/36rylva56gst24je6isq/PHID-FILE-eppbmnjmm5fp7xhgoit6/site-defs.json):

List of existing phrase translations:

cs
de
en
es
fa
fi
fr
hu
id
it
ja
ko
nl
no
pl
pt
ru
sv
tr
uk
vi
zh

Update these languages:
"ceb": {

		"wiki": {
			"slogan": "Ang gawasnong ensiklopedya"
		}

}

"war": {

		"wiki": {
			"slogan": "An gawasnon nga ensayklopedya"
		}

},

"az": {

		"wiki": {
			"slogan": "Açıq ensiklopediya"
		}

},

"bg": {

		"wiki": {
			"slogan": "Cвободната енциклопедия"
		}

},

"ca": {

		"wiki": {
			"slogan": "L'enciclopèdia lliure"
		}

},

"da": {

		"wiki": {
			"slogan": "Den frie encyklopædi"
		}

}

"ga": {

		"wiki": {
			"slogan": "An Chiclipéid Shaor"
		}

},

debt added a subscriber: mpopov.May 24 2016, 12:12 AM

Let's take advantage of the work @mpopov has done with RCode and the API, as documented here: https://phabricator.wikimedia.org/T135759

Change 289153 merged by jenkins-bot:
T133729 New approach to localizing top-ten links using ajax & localstorage.

https://gerrit.wikimedia.org/r/289153

TheDJ added a subscriber: TheDJ.May 24 2016, 10:32 PM

Hmm. just saw this.. Has this usage of localstorage been checked with our cookie policy ?

Also. JSON.parse should be wrapped in try/catch, because defensive programming :)

@TheDJ thanks for taking a look at this. I've read the cookie policy and at first glance it seems that local storage is treated differently than cookies. I will consult with other developers at the foundation today to see if any further measures should be taken when using localStorage.

At the very least, I'll update the cookie policy to include the localStorage items used by the portal. It seems to me that this specific usage (language preferences) would fall into the 'preferences' category, similar to the other language related localStorage items.

Regarding JSON.parse, sure thing. will do.

Change 290652 had a related patch set uploaded (by Jdrewniak):
Revert "T133729 New approach to localizing top-ten links" This reverts commit 68953f91f1865b3c314d0c95ffe3829b499fcc15.

https://gerrit.wikimedia.org/r/290652

Change 290652 merged by jenkins-bot:
Revert "T133729 New approach to localizing top-ten links" This reverts commit 68953f91f1865b3c314d0c95ffe3829b499fcc15.

https://gerrit.wikimedia.org/r/290652

Change 291912 had a related patch set uploaded (by Jdrewniak):
T133729 New approach to localizing top-ten links using ajax & localstorage.

https://gerrit.wikimedia.org/r/291912

Change 291912 merged by jenkins-bot:
T133729 New approach to localizing top-ten links using ajax & localstorage.

https://gerrit.wikimedia.org/r/291912

debt closed this task as Resolved.Jun 14 2016, 11:23 PM
debt moved this task from Done to Completed on the Discovery-Portal-Sprint board.Aug 12 2016, 8:02 PM