Page MenuHomePhabricator

Use MaxMind translations in country and location data
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

IPInfo currently displays MaxMind data in English only. We did an investigation into how to make translations available: T266273. Providing full coverage will be complicated (see the linked task for more detail).

To start with, we can use the translations that MaxMind provides for location data. It does not have full coverage in terms of which locations have translations, or which languages they are translated into. (See an example in: T266273#8184182.) But it would be an improvement and is relatively straightforward to implement.

What needs to be done

geoip2's Reader class accepts an array of locales in its constructor - documented here. Currently IPInfo does not pass anything in, so ['en'] is used by default.

IPInfo's ReaderFactory::get method could be updated to accept an array of locales, which it passes on to Reader.

We should pass the entire fallback chain, which can be obtained from LanguageFallback::getAll, along with the user's preferred language code.

Acceptance criteria
  • Where MaxMind has a more appropriate translation than English, use that for country and location data
  • Where MaxMind does not have a more appropriate translation than English, use English (i.e. no change from the current behaviour)

Event Timeline

Tchanders set the point value for this task to 3.Aug 30 2022, 5:21 PM

@Prtksxna Should we have any disclaimer or notice about the fact that these translations are not ours, and can't be changed via our translation system? (Thanks @TThoabala for raising this.)

That is a good point, something I hadn't considered before. Do you know if there is any precedent for this? Do we use others' translations anywhere else in MediaWiki?

I think we could continue this task as is and create a follow-up for the disclaimer if we need it.

Change 830673 had a related patch set uploaded (by AGueyte; author: AGueyte):

[mediawiki/extensions/IPInfo@master] WIP

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

Change 830673 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Use MaxMind translations in country and location data

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

@STran Could you add some testing steps to this task? Thanks!

dom_walden subscribed.

I tested both the infobox on Special:Contributions and the popup for languages en, de, fr, es, pt-br, zh-cn, ru and ja. Compared the translations for Location (City, Subdivision(s) and Country) with my own script.

I then tested the language fallback chain:

  • pt -> pt-br
  • zh -> zh-cn
  • frc -> fr
  • oc -> cr -> fr
  • avk -> fr, es or ru (in that order of preference)

In the case of avk (Kotava), it chooses the closest fallback for City, Subdivision and Country independently, rather than trying to have them all fallback to the same language. This can mean they can all be in different languages.

For example, 1.0.81.0 only has a Russian translation for City so it returns "Мацуэ[ru], Préfecture de Shimane[fr], Japon[fr]" (brackets are mine), even though there are Russian translations for the Subdivision and Country.

For 1.34.143.0 it returns "Ciudad de Yilan[es], Yilan[en], Taïwan[fr]", even though there is a Spanish translation for the Country.

I did some brief experiments with how other parts of MediaWiki treat avk and this is how it works elsewhere. It is possibly desirable.

IPs tested:

  • 2001:240:2000:0:0:0:0:0
  • 1.0.81.0
  • 1.0.64.0
  • 2.15.39.166

Test environment: local docker IP Info 0.0.0 (d6dc857) 07:12, 16 November 2022.