mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
125 stars 41 forks source link

AMO API translations don't fall back to short locale when longer one isn't available for the add-on #1883

Open Rob--W opened 2 years ago

Rob--W commented 2 years ago

Describe the problem and steps to reproduce it:

Originally filed in https://bugzilla.mozilla.org/show_bug.cgi?id=1765023. When Firefox's locale is changed to non-en-US, to Spanish (en-MX) for example and install an add-on, then the add-on details should be localized.

What happened?

The add-on details in about:addons are not localized.

What did you expect to happen?

The add-on details should be localized.

Anything else we should know?

This URL is requested by the Addons manager to fetch the details. The results are en-US: https://services.addons.mozilla.org/api/v4/addons/search/?guid=adguardadblocker@adguard.com&lang=es-MX

Note that the results are English. If I request the following URL instead, the expected results are output: https://services.addons.mozilla.org/api/v4/addons/search/?guid=adguardadblocker@adguard.com&lang=es

Not sure if related, but AMO's frontend also ignores the language codes: https://addons.mozilla.org/es-ES/firefox/addon/adguard-adblocker/ -> 301 redirect to en-US https://addons.mozilla.org/es-MX/firefox/addon/adguard-adblocker/ -> 301 redirect to en-US https://addons.mozilla.org/es/firefox/addon/adguard-adblocker/ served in Spanish.

According to willdurand , some locales are mapped at the following location. Not sure if relevant, but mentioning just in case it is: https://github.com/mozilla/addons-frontend/blob/c0c4fa07af402987fd494cab483a2a92844127a9/config/default.js#L259

┆Issue is synchronized with this Jira Task

willdurand commented 2 years ago

According to @willdurand , some locales are mapped at the following location. Not sure if relevant, but mentioning just in case it is: mozilla/addons-frontend@c0c4fa0/config/default.js#L259

This is relevant for what's above (and now quoted below):

Not sure if related, but AMO's frontend also ignores the language codes: addons.mozilla.org/es-ES/firefox/addon/adguard-adblocker -> 301 redirect to en-US addons.mozilla.org/es-MX/firefox/addon/adguard-adblocker -> 301 redirect to en-US addons.mozilla.org/es/firefox/addon/adguard-adblocker served in Spanish.

Anyway, the problem here is that the add-on has two translations for en-US (default) and es but the FF instance uses a langpack for es-MX. I am not sure we can fallback to the short locale (i.e. es) when a long locale isn't supported and its short locale is available but that could be a quick win.

diox commented 2 years ago

Note that frontend redirects and fallback locale in the API are 2 very different things. In the API, it's extremely difficult to do that dynamic fallback efficiently without potentially creating extra SQL queries (and even if we allow additional queries it's not trivial). In the frontend it's certainly easier.

KevinMind commented 5 months ago

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDSRV-99