Page MenuHomePhabricator

Pass context language through to IPInfo API
Closed, DeclinedPublic3 Estimated Story Points

Description

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:

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.

Event Timeline

Tchanders set the point value for this task to 3.Oct 11 2022, 5:25 PM

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

[mediawiki/extensions/IPInfo@master] Pass context language through to IPInfo API

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

moving this back to in progress as Investigate new approach, possible going to abandon the patch and decline this task. just trying to create relevant task before I close this one.

Change 850617 abandoned by TsepoThoabala:

[mediawiki/extensions/IPInfo@master] Pass context language through to IPInfo API

Reason:

Implementation of this to be done differently. https://phabricator.wikimedia.org/T322664

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

TThoabala closed this task as Declined.EditedNov 8 2022, 5:22 PM

The work on this ticket has moved to https://phabricator.wikimedia.org/T322664

We have decided to use a different approach on this , instead of passing the language to the API we will be returning a list of translations from the API and sifting through them to use the one relevant to the user.