addons icon indicating copy to clipboard operation
addons copied to clipboard

Declare language for user localized text

Open kumar303 opened this issue 7 years ago • 11 comments

Describe the problem and steps to reproduce it:

  • Browse the site in your default locale (such as French)
  • Go an add-on detail page where the default locale of the description is something other than French (say, English)

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?

  • This is important for screen readers.
  • The old site did it.
  • We should probably also include the dir attribute for right-to-left languages but I don't know what the practical usage of that is.
  • This should apply to all user localized data, such as reviews, version release notes, etc.

┆Issue is synchronized with this Jira Task

kumar303 avatar Aug 31 '17 19:08 kumar303

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.

muffinresearch avatar Sep 11 '17 16:09 muffinresearch

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.

eviljeff avatar Sep 11 '17 17:09 eviljeff

Ah, right, I see

kumar303 avatar Sep 11 '17 21:09 kumar303

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.

diox avatar Nov 17 '17 11:11 diox

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 avatar Nov 20 '17 13:11 eviljeff

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.

eviljeff avatar Nov 16 '22 11:11 eviljeff

Commenting for assignment @eviljeff

GregSherman avatar Jun 06 '23 12:06 GregSherman

@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.

ioanarusiczki avatar Jun 07 '23 09:06 ioanarusiczki

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

diox avatar Jun 07 '23 11:06 diox

this was reverted, so reopening.

eviljeff avatar Jun 07 '23 15:06 eviljeff

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

KevinMind avatar May 03 '24 18:05 KevinMind