-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VPN-6778: fix English translations for addons w/ shared string #10123
Conversation
This might the highest ratio ever explanation vs code changes ;-) I never noticed the difference in I tried running automation (string extraction) against this branch, and the only difference is the target-language for
Any risk of strange behavior, especially on mobile where you might have locales like |
Sorry for the essay, I probably should have written a summary as well. (For what it's worth, it's probably the highest hours-put-in vs. characters-changed ratio I've ever done as well.)
I don't think changing the
Just tested out en-IN, and the app looked okay. |
I will add a step in the l10n repo to make sure the target-language of files in |
Sounds good, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thank you for the detailed notes.
Description
Short explanation: Deep in the translation build scripts,
en
is treated differently thanen-US
- it causes the script to think thaten-US
does not actually have any translations, and thus when switching toen
language it disables the addon. (This has not come up before for reasons explained in the essay below.)How does adding 3 characters allow us to use English addons that have shared strings? (This turned into an essay, sorry.)
translations.completeness
file to see if the addon is translated in the new languagetranslations.completeness
file for the addons using shared strings is showing0.0
foren
, when it should be showing1.0
translations.completeness
files for addons are created inbuild.py
, it's not being given a default of0.0
or being skipped or anything - it's being calculated as0.0
xlifftool.py
(which is called bybuild.py
)completeness
function, we find out it is correctly counting the number of source strings, but misreporting the number of translations as 0strings.xliff
file (from the translation repo) and the 2.25 addon'sstrings.xliff
file (built bybuild.py
because it uses shared strings), nothing jumps out - in both cases, neither showtarget
strings, justsource
strings.parse_filegroup
function (still inxlifftool.py
)... 2.24 English reports itself as a source language, 2.25 French reports itself as a target language... but 2.25 English reports itself as a target language (which is unexpected)!target-language
in the xliff file, and thesource-language
in the xliff file.xlifftool.py
:source-language="en" target-language="fr"
source-language="en" target-language="en-US"
source-language="en" target-language="en"
parse_filegroup
, iftarget-language
matches the reported locale, it reports the language is the target. Otherwise if thesource-language
it the reported locale, it reports the language is the source.target-language
is checked beforesource-language
is checked, and it matches. Thus, the fact that 2.24 English reports a source language ofen
and target ofen-US
isn't just a happy accident, but it is essential to ensuring the translation pipeline works as expected for the base English locale. Somewhere we translate anen
to an target ofen-US
.extract_source_strings.py
- it manually sets thetarget-language
toen-US
when ingesting new strings.en
target?build.py
takes the shared stringsstrings.xliff
file (from the translation repo) and builds the an addon-specific temporary xliff file for each addon (this generated file should have identical formatting to the legacy addon-specific xliff files from the translations repo)build.py
stransform_shared_strings function
, it essentially copies the headers from the shared stringsstrings.xliff
file. (If I manually change thestrings.xliff
file in3rdparty/i18n/
to have a target language ofen-US
, it works as expected - so this is definitely the right path!)strings.xliff
file get its (incorrect) headers?shared.py
'swrite_en_language
, we have this line:ts.set("language", "en”)
. And if you change thaten
toen-US
the header's source language stays asen
but the target language changes toen-US
. 🎉🎉🎉This
ts.set("language", "en”)
line formerly lived inbuild.py
, and was copied to a new file as part of the initial shared strings work. This line is 2.5 years old, and seemingly never caused an issue until now. I was curious why it hadn't caused an issue until now?update.yaml
, 4 sets of translation files are ingested by the l10n repo:mozillavpn.xliff
(most of translations for the client) - is built viaextract_source_strings.py
, which gives the properen-US
extras.xliff
(languages names and servers cities/countries) - this is a direct copy, but the bug doesn't arrise. For language names, there is a manual check for theen
case ingenerate_language_names_map.py
. For server, the code doesn't directly look at thetarget-language
string, so there isn't an issue. (There is one more spot this file is used that I didn't investigate, as it didn't seem worth the time to dig even deeper here.)strings.xliff
file for each addon (that doesn't use shared strings) - these are built viaextract_source_strings.py
, which gives the properen-US
strings.xliff
file for addon shared strings - this is a direct copy from whatbuild.py
outputs, and so it keeps those incorrect headers it was initially given... until this PRFrom quick testing, this PR doesn't have any negative side effects on the existing client translations.
After this is merged, we'll need the following steps before the bug will appear fixed:
Reference
VPN-6778
Checklist