mozilla / addons

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

Declare language for user localized text #2025

Open kumar303 opened 7 years ago

kumar303 commented 7 years ago

Describe the problem and steps to reproduce it:

What happened?

The section of the text in English does not have a lang attribute which means it will be interpreted as French (or whatever locale is in the URL).

What did you expect to happen?

It should have a lang attribute specifying the locale.

Anything else we should know?

┆Issue is synchronized with this Jira Task

muffinresearch commented 7 years ago

I mentioned this case to @eviljeff and he pointed out that if you specify lang in an API request you'll get only the locale you asked for. This however will fall back to other locales e.g. if you request lang=fr some descriptions will be in french but others will be in English but there's no data to be able to know that a given description is not the locale you requested.

To fix this we will need a fairly extensive breaking change in the API to annotate all localized content with the locale of the actual data returned to support this case.

eviljeff commented 7 years ago

For reference http://addons-server.readthedocs.io/en/latest/topics/api/overview.html#api-overview-translations is what we do at the moment.

We could change the API to always return a dict (with only the requested locale, or the default locale otherwise). But that would be a breaking change as mentioned (I don't know how reliant frontend is on the existing behavior). Or add another param that would return the dict, or some other structure that indicates the locale of each property.

@diox and @EnTeQuAk to look and ponder|despair.

kumar303 commented 7 years ago

Ah, right, I see

diox commented 6 years ago

We could change the API to always return a dict (with only the requested locale, or the default locale otherwise)

That would be my preference, because more query parameters are awful, but... backwards-compatibility breakage :( Still, the frontend could be modified in advance to cope with this change maybe? The APIs are marked as experimental in the docs precisely to allow us to do things like that, we don't guarantee their stability to the outside world.

eviljeff commented 6 years ago

Okay, so essentially I think we're agreed on always returning a dict for localised values. As its a breaking change frontend will need to do the work beforehand to handle it, or at least have the patch ready to merge. I don't think the API change is massive so shouldn't be much work on the addons-server side (though there will be many, many, test changes)

eviljeff commented 1 year ago

fwiw, this isn't blocked on API changes (and hasn't been for a few years) - the API response always indicates the locale of any localised field now.

GregSherman commented 1 year ago

Commenting for assignment @eviljeff

ioanarusiczki commented 1 year ago

@GregSherman

Should name also have the lang attribute?

name

There's a lang attribute for summary, description, developer comments and e-mail:

summary description developer comments email

I'll cc @eviljeff in case Greg won't see the results.

diox commented 1 year ago

This likely caused https://github.com/mozilla/addons/issues/14677

eviljeff commented 1 year ago

this was reverted, so reopening.

KevinMind commented 4 months ago

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDFRNT-119