Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 6257416f by Pier Angelo Vendrame at 2025-03-25T18:07:01+01:00 Bug 41400: Add our localization to GeckoView.
We need our branding files as not having them prevents us from debugging our official builds from about:debugging.
Rather than duplicating the code for l10n (even more), in this commit we move the string files setup from firefox to a shared script.
- - - - -
10 changed files:
- + projects/common/browser-localization - projects/firefox/rename-branding-strings.py → projects/common/rename-branding-strings.py - projects/firefox/build - projects/firefox/config - projects/geckoview/build - projects/geckoview/build_ac_fenix - projects/geckoview/build_apk - projects/geckoview/build_common - projects/geckoview/config - rbm.conf
Changes:
===================================== projects/common/browser-localization ===================================== @@ -0,0 +1,106 @@ +branding_dir=[% IF c('var/android') %]mobile/android[% ELSE %]browser[% END %]/branding/[% c("var/project_initials") %]-[% c("var/channel") %] + +[% IF c("var/has_l10n") -%] + [% IF !c("var/android") -%] + supported_locales="[% tmpl(c('var/locales').join(' ')) %]" + [% ELSE -%] + supported_locales="[% tmpl(c('var/locales_mobile').join(' ')).replace('-r', '-').replace('in', 'id').replace('iw', 'he') %]" + [% END %] + + l10ncentral="$HOME/.mozbuild/l10n-central" + mkdir "$l10ncentral" + [% IF c('input_files_by_name/firefox-l10n') -%] + for tarball in $rootdir/[% c('input_files_by_name/firefox-l10n') %]/*; do + tar -C "$l10ncentral" -xf "$tarball" + done + [% END -%] + + [% IF c('input_files_by_name/translation-base-browser') -%] + tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-base-browser') %]" + pushd "$rootdir/translation-base-browser" + ln -s ja ja-JP-mac + for lang in $supported_locales; do + mv $lang/base-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" + done + popd + [% END -%] + + [% IF c('input_files_by_name/translation-tor-browser') -%] + tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-tor-browser') %]" + + [%# + # For the purpose of Weblate, all releases share a single brand.ftl and + # brand.properties file per locale in the translations repository. + # See tor-browser-build#41372. + # In brand.ftl, both `-brand-short-name` and `-brand-full-name` should + # differ between releases. As such, they have additional entries in the + # translations repository file (Weblate): + # -brand-short-name for the stable release. + # -brand-short-name_alpha for the alpha release. + # -brand-short-name_nightly for the nightly release. + # And similarly for -brand-full-name. + # For the final build, we only want to keep the string that matches the + # built release, and remove its suffix if it has one. So for the stable + # release we want to keep -brand-short-name. For the alpha release we want + # to keep -brand-short-name_alpha instead, and rename it to be + # -brand-short-name. + # + # As such, we parse the brand.ftl file to rename these strings to keep the + # version we want using rename-branding-strings.py. + # + # We do a similar thing with brandShortName and brandFullName in + # brand.properties. + -%] + + # For the stable release, the suffix is empty. + # I.e. we want to select `-brand-short-name` directly. + [% IF !c("var/release"); branding_string_suffix = '_' _ c('var/channel'); END -%] + + # Instructions for the script to perform the renames. + brand_ftl_renames='{ + "suffix": "[% branding_string_suffix %]", + "ids": ["-brand-short-name", "-brand-full-name"] + }' + brand_properties_renames='{ + "suffix": "[% branding_string_suffix %]", + "ids": ["brandShortName", "brandFullName"] + }' + + pushd "$rootdir/translation-tor-browser" + ln -s ja ja-JP-mac + for lang in $supported_locales; do + mv $lang/tor-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" + # Branding. + l10n_branding_dir="$l10ncentral/$lang/$branding_dir/" + mkdir -p "$l10n_branding_dir" + # Convert the translations repository branding files into files that work + # for this specific build. + python3 $rootdir/rename-branding-strings.py $lang/branding/brand.ftl "$brand_ftl_renames" > "$l10n_branding_dir/brand.ftl" + python3 $rootdir/rename-branding-strings.py $lang/brand.properties "$brand_properties_renames" > "$l10n_branding_dir/brand.properties" + done + popd + + [% IF !c('var/android') -%] + # torbutton properties files. + # TODO: Remove once we no longer have torbutton locale files. + torbutton_locales="toolkit/torbutton/chrome/locale/" + torbutton_jar="toolkit/torbutton/jar.mn" + for lang in $supported_locales; do + mkdir -p "$torbutton_locales/$lang" + mv "$rootdir/translation-tor-browser/$lang"/*.properties "$torbutton_locales/$lang/" + echo "% locale torbutton $lang %locale/$lang/" >> "$torbutton_jar" + echo " locale/$lang (chrome/locale/$lang/*)" >> "$torbutton_jar" + done + [% END -%] + [% ELSIF c('input_files_by_name/translation-mullvad-browser') -%] + tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-mullvad-browser') %]" + pushd "$rootdir/translation-mullvad-browser" + ln -s ja ja-JP-mac + for lang in $supported_locales; do + cp -Lr $lang "$l10ncentral/" + done + popd + [% END -%] +[% ELSE -%] + supported_locales="" +[% END -%]
===================================== projects/firefox/rename-branding-strings.py → projects/common/rename-branding-strings.py =====================================
===================================== projects/firefox/build ===================================== @@ -114,97 +114,7 @@ export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # Create .mozbuild to avoid interactive prompt in configure mkdir "$HOME/.mozbuild"
-branding_dir=browser/branding/[% c("var/branding_directory_prefix") %]-[% c("var/channel") %] - -[% IF c("var/has_l10n") -%] - supported_locales="[% tmpl(c('var/locales').join(' ')) %]" - - l10ncentral="$HOME/.mozbuild/l10n-central" - mkdir "$l10ncentral" - for tarball in $rootdir/[% c('input_files_by_name/firefox-l10n') %]/*; do - tar -C "$l10ncentral" -xf "$tarball" - done - - tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-base-browser') %]" - pushd "$rootdir/translation-base-browser" - ln -s ja ja-JP-mac - for lang in $supported_locales; do - # Fluent - mv $lang/base-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" - done - popd - - [% IF c("var/tor-browser") -%] - tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-tor-browser') %]" - - # For the purpose of Weblate, all releases share a single brand.ftl and - # brand.properties file per locale in the translations repository. - # See tor-browser-build#41372. - # In brand.ftl, both `-brand-short-name` and `-brand-full-name` should - # differ between releases. As such, they have additional entries in the - # translations repository file (Weblate): - # -brand-short-name for the stable release. - # -brand-short-name_alpha for the alpha release. - # -brand-short-name_nightly for the nightly release. - # And similarly for -brand-full-name. - # For the final build, we only want to keep the string that matches the - # built release, and remove its suffix if it has one. So for the stable - # release we want to keep -brand-short-name. For the alpha release we want - # to keep -brand-short-name_alpha instead, and rename it to be - # -brand-short-name. - # - # As such, we parse the brand.ftl file to rename these strings to keep the - # version we want using rename-branding-strings.py. - # - # We do a similar thing with brandShortName and brandFullName in - # brand.properties. - - # Instructions for the script to perform the renames. - brand_ftl_renames='{ - "suffix": "[% c("var/branding_string_suffix") %]", - "ids": ["-brand-short-name", "-brand-full-name"] - }' - brand_properties_renames='{ - "suffix": "[% c("var/branding_string_suffix") %]", - "ids": ["brandShortName", "brandFullName"] - }' - - pushd "$rootdir/translation-tor-browser" - ln -s ja ja-JP-mac - for lang in $supported_locales; do - mv $lang/tor-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" - # Branding. - l10n_branding_dir="$l10ncentral/$lang/$branding_dir/" - mkdir -p "$l10n_branding_dir" - # Convert the translations repository branding files into files that work - # for this specific build. - python3 $rootdir/rename-branding-strings.py $lang/branding/brand.ftl "$brand_ftl_renames" > "$l10n_branding_dir/brand.ftl" - python3 $rootdir/rename-branding-strings.py $lang/brand.properties "$brand_properties_renames" > "$l10n_branding_dir/brand.properties" - done - popd - - # torbutton properties files. - # TODO: Remove once we no longer have torbutton locale files. - torbutton_locales="toolkit/torbutton/chrome/locale/" - torbutton_jar="toolkit/torbutton/jar.mn" - for lang in $supported_locales; do - mkdir -p "$torbutton_locales/$lang" - mv "$rootdir/translation-tor-browser/$lang"/*.properties "$torbutton_locales/$lang/" - echo "% locale torbutton $lang %locale/$lang/" >> "$torbutton_jar" - echo " locale/$lang (chrome/locale/$lang/*)" >> "$torbutton_jar" - done - [% ELSIF c("var/mullvad-browser") -%] - tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-mullvad-browser') %]" - pushd "$rootdir/translation-mullvad-browser" - ln -s ja ja-JP-mac - for lang in $supported_locales; do - cp -Lr $lang "$l10ncentral/" - done - popd - [% END -%] -[% ELSE -%] - supported_locales="" -[% END -%] +[% INCLUDE 'browser-localization' %]
# PyYAML tries to read files as ASCII, otherwise export LC_ALL=C.UTF-8
===================================== projects/firefox/config ===================================== @@ -21,7 +21,6 @@ var: browser_rebase: 1 browser_branch: '[% c("var/browser_series") %]-[% c("var/browser_rebase") %]' browser_build: 3 - branding_directory_prefix: 'tb' copyright_year: '[% exec("git show -s --format=%ci " _ c("git_hash") _ "^{commit}", { exec_noco => 1 }).remove("-.*") %]' nightly_updates_publish_dir: '[% c("var/nightly_updates_publish_dir_prefix") %]nightly-[% c("var/osname") %]' gitlab_project: https://gitlab.torproject.org/tpo/applications/tor-browser @@ -55,10 +54,6 @@ var: rm -Rf "$rezip_tmpdir"
l10n-changesets: '[% exec("git --no-pager show " _ c("git_hash") _ ":browser/locales/l10n-changesets.json", { exec_noco => 1 }) %]' - # The branding_string_suffix for the alpha and nightly should be - # '_alpha' and '_nightly', matching the "suffix" chosen in the - # tor-browser:update-translations.yml file. - branding_string_suffix: '_[% c("var/channel") %]'
steps: src-tarballs: @@ -99,12 +94,6 @@ targets: var: nightly_updates_publish_dir_prefix: basebrowser-
- release: - var: - # For the stable release, the suffix is empty. - # I.e. we want to select `-brand-short-name` directly. - branding_string_suffix: '' - nightly: git_hash: '[% c("var/project-name") %]-[% c("var/firefox_version") %]-[% c("var/browser_branch") %]' tag_gpg_id: 0 @@ -114,7 +103,6 @@ targets: mullvadbrowser: git_url: https://gitlab.torproject.org/tpo/applications/mullvad-browser.git var: - branding_directory_prefix: 'mb' gitlab_project: https://gitlab.torproject.org/tpo/applications/mullvad-browser updater_url: 'https://cdn.mullvad.net/browser/update_responses/update_1/' nightly_updates_publish_dir_prefix: mullvadbrowser-
===================================== projects/geckoview/build ===================================== @@ -33,6 +33,7 @@ export MOZ_SOURCE_CHANGESET=[% c("var/git_commit") %]
ac_add_options --enable-update-channel=[% c("var/variant") %] MOZCONFIG_EOF +echo "ac_add_options --with-branding=$branding_dir" >> .mozconfig
echo "Starting ./mach configure $(date)" ./mach configure \
===================================== projects/geckoview/build_ac_fenix ===================================== @@ -1,15 +1,5 @@ [% IF c('var/has_l10n') -%] echo "Injecting the Firefox's localization to GV $(date)" - supported_locales="[% tmpl(c('var/locales_mobile').join(' ')).replace('-r', '-').replace('in', 'id').replace('iw', 'he') %]" - l10ncentral="$HOME/.mozbuild/l10n-central" - mkdir "$l10ncentral" - for tarball in $rootdir/[% c('input_files_by_name/firefox-l10n') %]/*; do - tar -C "$l10ncentral" -xf "$tarball" - done - - # Do not setup our localization files, as we do not provide any frontend - # through GeckoView. - # No quotes on purpose, to pass each locale as an additional argument. ./mach package-multi-locale --locales en-US $supported_locales [% END -%]
===================================== projects/geckoview/build_apk ===================================== @@ -24,7 +24,10 @@ mk_add_options MOZ_PARALLEL_BUILD=[% c("num_procs") %] export MOZ_INCLUDE_SOURCE_INFO=1 export MOZ_SOURCE_REPO="[% c('var/gitlab_project') %]" export MOZ_SOURCE_CHANGESET=[% c("var/git_commit") %] + +ac_add_options --enable-update-channel=[% c("var/variant") %] MOZCONFIG_EOF +echo "ac_add_options --with-branding=$branding_dir" >> mozconfig-android-all
# We still need to specify --tor-browser-version due to bug 34005. ./mach configure \
===================================== projects/geckoview/build_common ===================================== @@ -47,3 +47,5 @@ cp -rl oss-licenses-plugin/. $gradle_repo export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # Create .mozbuild to avoid interactive prompt in configure mkdir "$HOME/.mozbuild" + +[% INCLUDE 'browser-localization' %]
===================================== projects/geckoview/config ===================================== @@ -106,6 +106,11 @@ steps: project: translation pkg_type: fenix enable: '[% c("var/has_l10n") %]' + - name: translation-tor-browser + project: translation + pkg_type: tor-browser + enable: '[% c("var/has_l10n") %]' + - filename: rename-branding-strings.py - URL: '[% pc("glean", "var/glean_wheels_url/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]' name: glean-wheels sha256sum: '[% pc("glean", "var/glean_wheels_sha256sum/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]' @@ -164,3 +169,8 @@ input_files: project: translation pkg_type: fenix enable: '[% c("var/android_single_arch") && c("var/has_l10n") %]' + - name: translation-tor-browser + project: translation + pkg_type: tor-browser + enable: '[% c("var/android_single_arch") && c("var/has_l10n") %]' + - filename: rename-branding-strings.py
===================================== rbm.conf ===================================== @@ -299,6 +299,7 @@ targets: projectname: torbrowser Project_Name: 'Tor Browser' ProjectName: TorBrowser + project_initials: tb
basebrowser: var: @@ -316,6 +317,7 @@ targets: projectname: mullvadbrowser Project_Name: 'Mullvad Browser' ProjectName: MullvadBrowser + project_initials: mb exe_name: mullvadbrowser mar_channel_id: '[% c("var/projectname") %]-mullvad-[% c("var/channel") %]' locales:
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/62...