diff --git a/Makefile b/Makefile index 49e9436..ea03e9d 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,7 @@ build : $(lw_source_dir) package : (cd $(lw_source_dir) && ./mach package) + (cd $(lw_source_dir) && cat browser/locales/shipped-locales | xargs ./mach package-multi-locale --locales) cp -v $(lw_source_dir)/obj-*/dist/librewolf-$(version)-$(release).en-US.*.tar.bz2 . run : diff --git a/assets/mozconfig.new b/assets/mozconfig.new index 751c264..c2a8d81 100644 --- a/assets/mozconfig.new +++ b/assets/mozconfig.new @@ -16,6 +16,8 @@ ac_add_options --with-branding=browser/branding/librewolf ac_add_options --with-unsigned-addon-scopes=app,system +ac_add_options --with-l10n-base=$PWD/browser/locales/l10n + export MOZ_REQUIRE_SIGNING= mk_add_options MOZ_CRASHREPORTER=0 diff --git a/scripts/generate-locales.sh b/scripts/generate-locales.sh new file mode 100755 index 0000000..7d3b29e --- /dev/null +++ b/scripts/generate-locales.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +if [ ! -f browser/locales/shipped-locales ]; then + echo "ERROR: Run this script from the root of the LibreWolf source code" + exit 1 +fi + +rm -rf browser/locales/l10n +mkdir browser/locales/l10n + +N=8 +for i in $(seq $N); do echo; done +total=$(wc -l < browser/locales/shipped-locales) + +echo_status() { + printf "\033[$((($N - $n) + 1))A$@ %40s\r\033[$((($N - $n) + 1))B" +} + +generate_locale() { + if echo " en-US ca ja " | grep -q " $1 "; then + echo_status "Skipping locale \"$1\"" + sleep 1 + echo_status + return + fi + echo_status "Downloading locale \"$1\"" + wget -q -O browser/locales/l10n/$1.zip https://hg.mozilla.org/l10n-central/$1/archive/tip.zip + echo_status "Extracting locale \"$1\"" + unzip -qo browser/locales/l10n/$1.zip -d browser/locales/l10n/ + mv browser/locales/l10n/$1-*/ browser/locales/l10n/$1/ + rm -f browser/locales/l10n/$1.zip + echo_status "Generating locale \"$1\"" + mv browser/locales/l10n/$1/browser/branding/official browser/locales/l10n/$1/browser/branding/librewolf + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla Firefox/LibreWolf/g' {} \; + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla/LibreWolf/g' {} \; + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Firefox/LibreWolf/g' {} \; + echo_status "Done" + sleep 0.3 + echo_status +} + +while read in; do + ((n=n%N)); ((n++==0)) && wait + generate_locale $in & +done < browser/locales/shipped-locales + +wait + +printf "\033[$(($N))A\rGenerated $total locales %-40s\n" diff --git a/scripts/librewolf-patches.py b/scripts/librewolf-patches.py index 06a7924..edaeee1 100755 --- a/scripts/librewolf-patches.py +++ b/scripts/librewolf-patches.py @@ -126,6 +126,9 @@ def librewolf_patches(): for file in ["browser/config/version.txt", "browser/config/version_display.txt"]: with open(file, "w") as f: f.write("{}-{}".format(version,release)) + + # generate locales + exec("bash ../scripts/generate-locales.sh") leave_srcdir()