mirror of
https://codeberg.org/librewolf/source.git
synced 2024-12-22 05:33:03 -05:00
Make lw translations work
This commit is contained in:
parent
f8c5b9e264
commit
eed271897f
11 changed files with 36 additions and 24 deletions
|
@ -17,7 +17,7 @@ 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
|
||||
ac_add_options --with-l10n-base=$PWD/browser/locales
|
||||
|
||||
ac_add_options --enable-bootstrap
|
||||
|
||||
|
|
0
l10n/README.md
Normal file
0
l10n/README.md
Normal file
|
@ -1,20 +0,0 @@
|
|||
#!/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
|
||||
|
||||
echo "-> Downloading locales"
|
||||
rm -rf browser/locales/l10n
|
||||
curl -o browser/locales/l10n.zip "https://codeload.github.com/mozilla-l10n/firefox-l10n/zip/refs/heads/main"
|
||||
unzip -qo browser/locales/l10n.zip -d browser/locales/
|
||||
mv browser/locales/firefox-l10n-main browser/locales/l10n
|
||||
rm -f browser/locales/l10n.zip
|
||||
|
||||
sourcedir="$(pwd)"
|
||||
set -x
|
||||
cd "../l10n/en-US"
|
||||
find . -name '*.ftl' -exec sh -c "mkdir -p \$(dirname $sourcedir/{}) && cat {} >> $sourcedir/{}" \;
|
||||
cd ..
|
||||
find . -name '*.ftl' -path en-US -prune -exec sh -c "mkdir -p \$(dirname $sourcedir/browser/locales/l10n/{}) && cat {} >> $sourcedir/browser/locales/l10n/{}" \;
|
|
@ -9,6 +9,8 @@ import os
|
|||
import sys
|
||||
import optparse
|
||||
import time
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
|
||||
#
|
||||
|
@ -145,9 +147,39 @@ def librewolf_patches():
|
|||
with open(file, "w") as f:
|
||||
f.write("{}-{}".format(version,release))
|
||||
|
||||
# generate locales
|
||||
exec("bash ../scripts/generate-locales.sh")
|
||||
|
||||
print("-> Downloading locales from https://github.com/mozilla-l10n/firefox-l10n")
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
exec(f"curl -o {tmpdir}/l10n.zip 'https://codeload.github.com/mozilla-l10n/firefox-l10n/zip/refs/heads/main'")
|
||||
exec(f"unzip -qo {tmpdir}/l10n.zip -d {tmpdir}/l10n")
|
||||
exec(f"mv {tmpdir}/l10n/firefox-l10n-main/* browser/locales")
|
||||
|
||||
print("-> Applying LibreWolf locales")
|
||||
l10n_dir = Path("..", "l10n")
|
||||
for source_path in l10n_dir.rglob("*"):
|
||||
if source_path.is_dir() or source_path.name.endswith(".md"):
|
||||
continue
|
||||
|
||||
|
||||
|
||||
rel_path = source_path.relative_to(l10n_dir)
|
||||
target_path = Path(
|
||||
"browser", "locales",
|
||||
rel_path.parts[0],
|
||||
*([] if rel_path.parts[0] == "en-US" else ["browser"]) ,
|
||||
*rel_path.parts[1:])
|
||||
target_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
write_mode = "w"
|
||||
if ".inc" in target_path.name:
|
||||
target_path = target_path.with_name(target_path.name.replace(".inc", ""))
|
||||
write_mode = "a"
|
||||
|
||||
print(f"{source_path} {">" if write_mode == "w" else ">>"} {target_path}")
|
||||
|
||||
with open(target_path, write_mode) as target_file:
|
||||
with open(source_path, "r") as source_file:
|
||||
target_file.write(("\n\n" if write_mode == "a" else "") + source_file.read())
|
||||
|
||||
leave_srcdir()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue