Open Bug 1825236 Opened 2 years ago Updated 2 years ago

Update languages.js to avoid manual translation

Categories

(Firefox :: Settings UI, task, P3)

Desktop
All
task

Tracking

()

Tracking Status
firefox113 --- affected

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

languages.js has an async component to loading the languages for its dialog at https://searchfox.org/mozilla-central/rev/42747dfd314e4c939dc7c33a13e1a2fddf4926fc/browser/components/preferences/dialogs/languages.js#39-41 and further down the calltree into _buildAvailableLanguageList() and so on.

Also, when adding/removing items, it rebuilds the available languages list completely.

Instead we could:

  1. create the list when DOMContentLoaded fires (or even synchronously as soon as the DOM is created).
  2. sort it synchronously when load fires (as that now guarantees translation has happened).
  3. use hidden to hide items that shouldn't show up in the dropdown, rather than rebuilding the entire list (which is slow, async, and expensive).

While we're doing this, we might want to add some test coverage as there does not appear to be any...

Severity: -- → N/A
Priority: -- → P3

I found bug 1764694 and tried to fix it, since it seemed pretty trivial. Then started adding tests – Up/Down/Remove have zero tests — and got completely lost because of this (I assume).

Moving one of the locales triggers a change in intl.accept_languages, which every time calls _readAcceptLanguages(). The problem is that, at this point, for tests richlistitem.selectedIndex always returns -1, I believe because await document.l10n.translateFragment() takes a lot longer. The only way I could make tests work is to manually set up selectedIndex to the item I wanted, which is not exactly correct.

You need to log in before you can comment on or make changes to this bug.