[meta] Add ability to build multi-locale/multilingual Firefox
Categories
(Firefox Build System :: General, enhancement)
Tracking
(Not tracked)
People
(Reporter: zbraniecki, Unassigned)
References
(Depends on 2 open bugs)
Details
(Keywords: meta, Whiteboard: [fidedi-multilocale])
| Reporter | ||
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
| Reporter | ||
Comment 3•8 years ago
|
||
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
| Reporter | ||
Comment 6•8 years ago
|
||
Comment 7•8 years ago
|
||
| Reporter | ||
Comment 8•8 years ago
|
||
Updated•8 years ago
|
| Reporter | ||
Comment 9•8 years ago
|
||
Comment 10•8 years ago
|
||
| Reporter | ||
Updated•8 years ago
|
| Reporter | ||
Comment 11•8 years ago
|
||
Updated•8 years ago
|
Comment 12•7 years ago
|
||
Comment 13•7 years ago
|
||
| Comment hidden (advocacy) |
Updated•7 years ago
|
| Comment hidden (advocacy) |
Comment 16•4 years ago
|
||
I've been looking into building multi-locale Firefox and have managed to get it working for en-US and one other locale. When attempting to build with more than one additional locale I'm still encountering some issues (highlighted at the end).
I've been using the below mach command:
- ./mach package-multi-locales --locales en-US de (now works)
- ./mach package-multi-locales --locales en-US de fr (doesn't work)
Once the multi-locale package begins after the build stages the below errors will be received (building on Mac, so platform specific and not main focus):
Error: $SRCDIR/browser/installer/package-manifest.in:44: Missing file(s): Nightly.app/Contents/Resources/multi.lproj/*
As the app name remains consistent regardless of locale, the following lines can be added to browser/installer/package-manifest.mk starting at line 44:
#if __LPROJ_ROOT__ == en
@RESPATH@/@LPROJ_ROOT@.lproj/*
#endif
This hack removes the requirement for a locale specific .lproj folder to exist, although the ideal solution would be to make sure that the folders are correctly created for all specified locales. This does, however, resolve the error from above which allows the packaging to get slightly further along although it will now fail with the below:
RuntimeError: File "necko.properties" not found in $objdir/browser/locales/merge-dir/multi/netwerk
This is because AB_CD is set as multi so the packaging is looking for merge-dir/multi which doesn't exist, rather than merge-dir/<locale> (which does exist for all supplied locales). To resolve this I implemented the below in python/mozbuild/mozbuild/mach_commands.py, starting at ~line 1591:
for locale in locales:
if locale == 'en-US':
self.log(logging.INFO, 'package-multi-locale', {'locale': locale},
'Skipping default locale {locale}')
continue
self.log(logging.INFO, 'package-multi-locale', {'locale': locale},
'Invoking multi-locale `mach package`, {locale}')
self._run_make(
directory=self.topobjdir,
target=['package', 'AB_CD={}'.format(locale)],
append_env=append_env,
pass_thru=True,
ensure_exit_code=True)
This then allows a multi (2) locale build of Firefox to successfully be packaged.
Current Issues
Where the above begins to fail is when attempting to build a true multi locale package, with more than one additional locale. The build stage will still complete “successfully” however only the merge-dir/<locale> will be generated successfully, with the relevant chrome folders in the objdir not being generated for any aside from the first additional locale. This produces the below errors:
Error: $OBJDIR/browser/installer/locale-manifest.in:4: Missing file(s): Nightly.app/Contents/Resources/browser/chrome/fr
Error: $OBJDIR/browser/installer/locale-manifest.in:5: Missing file(s): Nightly.app/Contents/Resources/browser/chrome/fr.manifest
Error: $OBJDIR/browser/installer/locale-manifest.in:6: Missing file(s): Nightly.app/Contents/Resources/chrome/fr
Error: $OBJDIR/browser/installer/locale-manifest.in:7: Missing file(s): Nightly.app/Contents/Resources/chrome/fr.manifest
Which is the same as what happens for one additional locale before adding "GRADLE_INVOKED_WITHIN_MACH_BUILD": "1" to append_env in mach_commands.py. So my question here is, why are the relevant chrome and browser/chrome files generated for the first additonal locale, but not for the second? The browser/locales/merge-dir/<locale> files are generated correctly for all additional locales.
Could you assist in where would be a good place to do some more investigation for this? Where is the generation of the chrome and browser/chrome files controlled (assuming one or more of the jar.mn) and why would this only work for the first ./mach build chrome-<locale> called from ./mach package-multi-locales and not for any subsequent one's?
Comment 17•4 years ago
|
||
Adam, this is complicated and my memory is somewhat hazy. But let me try to help as I can.
I started to say that you will need to look at and understand the differences between Desktop's packaging and Android's packaging as well as some subtleties around the multi locale, but then I realized that I couldn't really follow-up without digging into the code. Rather than give too much explanation, I will suggest the following patch (which you might test) which works for me. The key issue you saw was not running mach build browser/app/tools or its equivalent: that populates the Contents/Resources directory. I have not verified that the resulting package has a healthy omnijar, although I expect it does. I have verified that in the Browser Console, we have
Cc["@mozilla.org/intl/localeservice;1"].getService(Ci.mozILocaleService).availableLocales == [ "de", "en-US", "fr" ]
and that
Services.prefs.setCharPref("intl.locale.requested", "fr");
does in fact change the localization of the browser. (Also, that "de" succeeds.) Play with this and see if I have missed anything more here?
diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -2015,15 +2015,34 @@ class L10NCommands(MachCommandBase):
cwd=mozpath.join(self.topsrcdir),
)
+ if self.substs["MOZ_BUILD_APP"] == "browser":
+ self.log(
+ logging.INFO,
+ "package-multi-locale",
+ {},
+ "Repackaging browser",
+ )
+ self._run_make(
+ directory=mozpath.join(self.topobjdir, "browser", "app"),
+ target=["tools"],
+ append_env=append_env,
+ pass_thru=True,
+ ensure_exit_code=True,
+ )
+
self.log(
logging.INFO,
"package-multi-locale",
{},
"Invoking multi-locale `mach package`",
)
+ target = ["package"]
+ if self.substs["MOZ_BUILD_APP"] == "mobile/android":
+ target.append("AB_CD=multi")
+
self._run_make(
directory=self.topobjdir,
- target=["package", "AB_CD=multi"],
+ target=target,
append_env=append_env,
pass_thru=True,
ensure_exit_code=True,
Comment 18•4 years ago
|
||
Thanks so much for the explanation and the patch here Nick! Confirming that I've tested this and all seems to be working accordingly.
Comment 19•3 years ago
|
||
(In reply to Zibi Braniecki [:zbraniecki][:gandalf] from comment #8)
I agree that rebuilding locales should be easy - similar maybe to the
"faster" mode to avoid all the c++ pieces.But for that particular use case, down the road, I hope we'll use pseudo
locales :)
Zibi: could you say a few words about what you were thinking here?
Comment 20•3 years ago
|
||
(In reply to Nick Alexander :nalexander [he/him] from comment #19)
(In reply to Zibi Braniecki [:zbraniecki][:gandalf] from comment #8)
I agree that rebuilding locales should be easy - similar maybe to the
"faster" mode to avoid all the c++ pieces.But for that particular use case, down the road, I hope we'll use pseudo
locales :)Zibi: could you say a few words about what you were thinking here?
Rats: NI to Zibi.
| Reporter | ||
Comment 21•3 years ago
|
||
Zibi: could you say a few words about what you were thinking here?
Did you just ask me willy-nilly what was I thinking 5 years ago? Ha! Bold! :)
My guess is that I was thinking that the use case of building Firefox with selected locales in order to test UI in those locales should be instead supplied by pseudo-locales.
And with repacks going away, the use case of "Give me Firefox with locale X" should be supplied by langpacks.
And the use case of "build Firefox with 4 locales for Switzerland" should be supplied by langpacks as well.
So, with repacks going away, the command of ./mach package --locales=de-CH,fr-CH,en-CH,it-CH should bundle four langpacks with Firefox rather than four locales in a repack.
Comment 22•3 years ago
|
||
(In reply to Zibi Braniecki [:zbraniecki][:gandalf] from comment #21)
Zibi: could you say a few words about what you were thinking here?
Did you just ask me willy-nilly what was I thinking 5 years ago? Ha! Bold! :)
I'm nothing if not optimistic :)
My guess is that I was thinking that the use case of building Firefox with selected locales in order to test UI in those locales should be instead supplied by pseudo-locales.
Ah, I follow you. Yes, we should use pseudo-locales for testing things in-product, absolutely.
And with repacks going away, the use case of "Give me Firefox with locale X" should be supplied by langpacks.
And the use case of "build Firefox with 4 locales for Switzerland" should be supplied by langpacks as well.So, with repacks going away, the command of
./mach package --locales=de-CH,fr-CH,en-CH,it-CHshould bundle four langpacks with Firefox rather than four locales in a repack.
We'll see where I get to in this direction.
Thanks!
Updated•3 years ago
|
Updated•3 years ago
|
Comment 23•3 years ago
|
||
I'm actively working on parts of this, so I'm going to make this a meta and break out some subtickets.
Updated•3 years ago
|
Updated•3 years ago
|
Description
•