Page MenuHomePhabricator

Normalise $langCodes format in IPInfo ReaderFactory::getReader()
Closed, ResolvedPublic

Description

Background

In T316665: Use MaxMind translations in country and location data and T318726: Pass context language through to IPInfo API, we are dealing with the user language code that could be returned in different formats.

We want to make sure that $langCodes passed is in the format read by Maxmind:
xx-XX (pr-BR or ch-ZN).
Right now, pt-br will default to English.

Acceptance Criteria
  • Any lang codes will be normalized to return the proper lang code format.
Testing notes

This can be tested on Beta.

I tested using test data from https://github.com/maxmind/MaxMind-DB, and the IP address 128.101.101.101.

I visited Special:Contributions for that IP address, having set my preferred language via Special:Preferences. I saw:

  • "United States" when using en
  • "Estados Unidos" when using es
  • Without this patch, "United States" when using pt-BR, but with this patch, "Estados Unidos" when using pt-BR

Note that the results are cached locally, so I tested with developer tools open on my browser (Chrome), and "Disable cache" checked under the "Network" tab, to ensure the results refreshed each time I changed my preferences.

Event Timeline

• AGueyte renamed this task from Normalise LangCode in ReaderFactory::getReader() to Normalise $langCodes format in IPInfo ReaderFactory::getReader().Oct 11 2022, 7:27 PM

Change 844441 had a related patch set uploaded (by TsepoThoabala; author: TsepoThoabala):

[mediawiki/extensions/IPInfo@master] Normalise $langCodes format in IPInfo ReaderFactory::getReader

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

Change 844441 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Normalise $langCodes format in IPInfo ReaderFactory::getReader

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

dom_walden subscribed.

I tested zh-cn and pt-br on a few different IP addresses. The correct translation showed for City, Subdivision and Country (I don't think the other data have translations).

IPs used (with MaxMind Enterprise data):

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

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