Mobile/Fennec/Android/Multilocale Builds

From MozillaWiki
< Mobile‎ | Fennec‎ | Android
Revision as of 02:40, 16 November 2016 by Ahunt (talk | contribs) (Created page with "Firefox for Android provides a locale switching system (which allows you to override the system locale). We ship with a large number of locales, however local builds default t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Firefox for Android provides a locale switching system (which allows you to override the system locale). We ship with a large number of locales, however local builds default to only including en-US. Here's a guide for building an apk with multiple locales locally. (Nightly and release builds are built with all locales included.)

A list of all the supported locales can be found at: http://hg.mozilla.org/l10n-central


Build recipe

  • Grab a copy of mozilla-central (or use an existing checkout)
  • Decide on the locales you desire, e.g. "ar zh-CN zh-TW pl de" (en-US will be included automatically), for simplicity dump these into a file called "multicocale-langs".
  • Download localisation repos: you can use the following script to do so:
 MOZILLA_CENTRAL=~/moz/hg/mozilla-central # edit to reflect current clone
 L10NBASEDIR=~/moz/hg/l10n # edit to reflect where your l10n checkouts will go
 
 LOCALES=$MOZILLA_CENTRAL/multilocale-conf
 mkdir -P $L10NBASEDIR
 pushd $L10NBASEDIR
 while read loc; do if ! [ -d "$loc" ]; then hg clone "http://hg.mozilla.org/releases/l10n/mozilla-aurora/$loc"; fi; done < $LOCALES
  • set up your mozconfig to include the following:
    • Note: only full (non-artifact builds are supported)
 mk_add_options 'export MOZ_CHROME_MULTILOCALE=en-US ar zh-CN zh-TW de pl' # start with en-US, and add your desired locales from (2)
 # Use absolute paths.
 mk_add_options 'export L10NBASEDIR=/Users/andrzejhunt/ff/hg/l10n' # should match L10NBASEDIR from earlier
 ac_add_options --with-l10n-base=/Users/andrzejhunt/ff/hg/l10n
  • build using |mach build|
  • build and merge the localisations:
    • edit the list below to include all your desired locales (do NOT include en-US, that was already built during |mach build|)
 for loc in ar pl de zh-TW; do  make -C objdir-frontend/mobile/android/locales merge-$loc LOCALE_MERGEDIR=/Users/andrzejhunt/ff/fx3/objdir-frontend/merge-$loc; make -C objdir-frontend/mobile/android/locales chrome-$loc LOCALE_MERGEDIR=/Users/andrzejhunt/ff/fx3/objdir-frontend/merge-$loc; done && ./mach package
  • |mach package| && |mach install| to test

Additional notes

  • The l10n-central locales can be out of date (i.e. will be missing some strings). The merge-$loc step merges locales with en-US, i.e. en-US strings will be used as a fallback for missing strings.
    • Locales that are complete therefore don't require the merge-$loc step, however as of writing only 6 locales were actually complete (missing strings will result in |mach package| failing due to xml errors / missing entities).
    • But chrome-$loc is still needed for every locale.
    • But aurora/beta/release builds usually won't need merge-$loc

The original multilocale guide can be found on Richard Newman's blog at http://160.twinql.com/building-and-testing-multi-locale-firefox-for-android/ . That blog also contains a plethora of other postings discussing multilocale support.