Page MenuHomePhabricator

Add language selector to Settings interface in pageviews tool
Closed, ResolvedPublic3 Story Points

Description

Once the pageviews tool has support for more than just English, we should add an interface in the Settings dialog to let people override the language with the language of their choice. The interface should only list the languages that have translations.

Event Timeline

kaldari created this task.Mar 3 2016, 6:31 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 3 2016, 6:31 PM
kaldari triaged this task as Normal priority.Mar 3 2016, 6:31 PM
kaldari moved this task from Untriaged to Bug backlog on the Community-Tech board.
DannyH set the point value for this task to 3.Mar 3 2016, 6:35 PM
DannyH moved this task from Bug backlog to Estimated on the Community-Tech board.
MusikAnimal added a comment.EditedMar 3 2016, 7:20 PM

My thoughts are we should have a dropdown at the bottom-right, just above the footer. The only reason for this is some users might not even figure out where the settings are due to the language barrier. A two-letter "en" in a clearly marked dropdown might give a big hint where to switch the language. The settings dialogue might be doomed as it is. With T126782 I don't think we need the search options anymore, issue #25 resulted in a compromise for colours, and most people are going to be OK with their i18n date/number formats.

I also think we should take advantage of JavaScript's navigator.language. That is, if there is no language cookie set, we could default to what the user's computer settings are set to (if translations exist). Speaking about implementation, we should have a pv.getLanguage() function that returns Intuition.language || navigator.language (or however we fetch the cookie value). Then we'll use this everywhere we do i18n, such as in pv.getLocaleDateString() and perhaps pv.n (number i18n).

What did you all think of the dropdown idea? I figure it's better to have it easily accessible. I can start work on this tonight, unless you're eager to do it :)

@MusikAnimal: I think just having a drop-down is fine. To retrieve all the supported languages, you can use Intuition::getAvailableLangs(). There are also some functions in there that demonstrate setting the cookie, but I assume you'll want to implement that on the client-side instead.

Alright, got a working language selector. Check it out at http://tools.wmflabs.org/pageviews-test

Since we don't have any translatewiki messages synced to our repo yet, I just made a test one for German. All it does is change the title. Try it out, then browse to tools.wmflabs.org/intuition to see that the preference carried over, and vice versa. I can also confirm that by default it correctly shows whatever language your browser is set to. If we don't have support for that language it shows English.

Let me know what you think!

@kaldari Got a pull request if you wish to review my PHP. See my comments there.

Alright, got a working language selector. Check it out at http://tools.wmflabs.org/pageviews-test

Looks pretty good. Thanks!

Aside, I went ahead and translated a lot of Hindi messages. :)

Niharika edited projects, added Community-Tech-Sprint; removed Community-Tech.
Niharika moved this task from Ready to Needs Review/Feedback on the Community-Tech-Sprint board.

Thanks @Niharika!

I've noticed a few problems... first it does not default to English for specific messages that are not translated. For instance see the Persian variation in it's current state: http://tools.wmflabs.org/pageviews-test/#start=2016-02-23&end=2016-03-13&project=en.wikipedia.org&platform=all-access&agent=user&pages=Cat|Dog

Not sure how to fix this... seems like maybe we'd need to dig into the Intuition source. @kaldari any ideas?

Additionally, some languages (such as Persian) need to be printed right-to-left. There's a CSS property that makes this easy to do, but we'll need to clean up the styling some to make it still look decent. I can take on this task. There's also some vertically written languages, I think, but I doubt we'll be able to support those :-/

@MusikAnimal: Strangely, falling back to English seems to work OK in some languages, like Polish. Not sure why it's failing in Persian.

Also works in Hindi. Might be some per-language setting?

kaldari added a comment.EditedMar 14 2016, 6:43 PM

It looks like the problem is that Western Balochi (what MusikAnimal referred to as Persian), is a language supported by Translatewiki, but not Wikipedia or Intuition. The two options here are:

  1. Limit the language selector to languages supported by Wikipedia and Intuition.
  2. Add support for Western Balochi to Intuition.
  3. Add code to Intuition to have it always fall back to English if the language isn't otherwise supported.

Actually, scratch that. It looks like the problem is that the language fallback chain for Western Balochi is just Persian (Farsi), but we don't have any Persian translations, and English is not in the fallback chain for some reason.

MusikAnimal added a comment.EditedMar 14 2016, 7:06 PM

Oh haha, I just put it into Google Translate and it detected it as Persian. Anyway, I see "bgn" at https://tools.wmflabs.org/intuition so I'm guessing it is supported by Intuition? I'm going to go ahead and deploy what we have. The missing translations for bgn are not critical.

I submitted a pull request upstream to fix this: https://github.com/Krinkle/intuition/pull/54

kaldari closed this task as Resolved.Mar 15 2016, 8:26 PM
kaldari moved this task from Needs Review/Feedback to Q1 2018-19 on the Community-Tech-Sprint board.

@kaldari Was this commit meant to fix the defaulting to English issue? I'm still seeing the placeholder text for Western Balochi.

This was fixed by running composer update to fetch the latest version of Intuition.

DannyH moved this task from Estimated to Archive on the Community-Tech board.Mar 28 2016, 10:34 PM