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.