Background
In T316665: Use MaxMind translations in country and location data, the IPInfo API returns information in the user's language, if it is available in MaxMind's database. (It uses the language fallback chain if not).
To detect the user's language, it uses a call to RequestContext::getMain()->getLanguage()->getCode(). This finds the user's langugae if set via preferences, or the site's content language. However, it does not find the uselang parameter if present in the original request, because this is not passed to the API.
Instead, we should pass the user's language to IPInfo's API endpoints. To ensure that the correct language is passed, whether set via the original request's query string, the user's preferences, or the site language, we can pass mw.config.values.wgUserLanguage.
The query to the API is built in the following places:
- https://gerrit.wikimedia.org/g/mediawiki/extensions/IPInfo/+/b712d04f2ac38d7f03aecf8126ee05e4f2001682/modules/ext.ipInfo/infobox/init.js#65
- https://gerrit.wikimedia.org/g/mediawiki/extensions/IPInfo/+/b712d04f2ac38d7f03aecf8126ee05e4f2001682/modules/ext.ipInfo/popup/init.js#53
Acceptance criteria
- ReaderFactory::getReader no longer calls RequestContext::getMain
- When a user views IPInfo with the uselang parameter set on their request, the data is displayed in that language, where available in MaxMind (otherwise the next appropriate language using the language fallback chain)
Notes
A consistent way to set specify language via the REST API is discussed in T269492: Selecting user language in the REST API. We may rework this part of IPInfo depending on the resolution to that discussion.