Further Unify Translations LangTag Matching
Categories
(Firefox :: Translations, task)
Tracking
()
People
(Reporter: nordzilla, Assigned: nordzilla)
References
Details
Attachments
(2 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
phab-bot
:
approval-mozilla-beta+
|
Details | Review |
Description
I did a further audit of language tag comparisons in the Translations ecosystem within Firefox, and noticed a few places that I missed in D231632.
❯ rg "(?i)((has|includes)\([a-z]*lang[a-z]*|[a-z]*lang[a-z]* +(==+|\!=+) +[a-z]*lang[a-z]*)" browser/components/translations toolkit/components/translations
toolkit/components/translations/TranslationsUtils.sys.mjs
75: if (lhsLangTag === rhsLangTag) {
toolkit/components/translations/actors/TranslationsParent.sys.mjs
1343: if (displayNames.has(langTag)) {
1889: if (!hasToPivot.has(lang)) {
1904: if (!hasFromPivot.has(lang)) {
3181: lazy.alwaysTranslateLangTags.has(docLangTag) ||
3197: lazy.neverTranslateLangTags.has(langTag) ||
3246: if (!langTags.has(langTag)) {
3285: mostRecentTargetLanguages.has(langTag) ||
3645: if (this.#detectedLanguages === detectedLanguages) {
browser/components/translations/tests/browser/browser_translations_about_preferences_settings_ui.js
233: getLangsFromPref(pref).includes(langTag),
255: !getLangsFromPref(pref).includes(langTag),
browser/components/translations/tests/browser/head.js
1724: return l10nArgs.language === expectedLanguageDisplayName;
2207: fromLanguage !== toLanguage &&
2212: if (fromLanguage === toLanguage) {
toolkit/components/translations/content/translations.mjs
165: this.fromLanguage !== fromLanguage ||
166: this.toLanguage !== toLanguage ||
242: data.fromLanguage === fromLanguage &&
243: data.toLanguage === toLanguage
682: ({ toLang }) => toLang === sourceLanguage
687: ({ fromLang }) => fromLang === targetLanguage
toolkit/components/translations/content/Translator.mjs
139: if (fromLanguage === toLanguage) {
315: if (fromLanguage !== toLanguage) {
toolkit/components/translations/content/translations-engine.worker.js
109: if (FULL_WIDTH_PUNCTUATION_LANGUAGE_TAGS.includes(sourceLanguage)) {
We should unify more of these locations to utilize TranslationsUtils.langTagsMatch().
I would also like to make TranslationsUtils.normalizeLangTagForTranslations() into a private function, because ultimately we just want to find a match, which is what the previous function is for.
Tests to implement
All of this should provide equivalent behavior to before and existing tests should be sufficient.
| Assignee | ||
Comment 1•1 year ago
|
||
This patch unifies more language-tag comparison locations to
utilize TranslationsUtils.langTagsMatch() instead of direct
string comparisons.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 3•1 year ago
|
||
| bugherder | ||
| Assignee | ||
Comment 4•1 year ago
|
||
This patch unifies more language-tag comparison locations to
utilize TranslationsUtils.langTagsMatch() instead of direct
string comparisons.
Original Revision: https://phabricator.services.mozilla.com/D233669
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Description
•