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.
Description
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | • Lea_WMDE | T143664 Improve page view statistics (#15) | |||
Resolved | None | T120497 Pageview Stats tool | |||
Resolved | MusikAnimal | T128770 Add language selector to Settings interface in pageviews tool | |||
Resolved | kaldari | T128768 Register pageviews tool with translatewiki.net | |||
Resolved | kaldari | T128103 Add i18n support to pageviews tool with Intuition |
Event Timeline
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.
Looks pretty good. Thanks!
Aside, I went ahead and translated a lot of Hindi messages. :)
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.
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:
- Limit the language selector to languages supported by Wikipedia and Intuition.
- Add support for Western Balochi to Intuition.
- 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.
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 Was this commit meant to fix the defaulting to English issue? I'm still seeing the placeholder text for Western Balochi.