0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2024-12-22 21:53:31 -05:00
LibreWolf/scripts/librewolf-patches.py
Malte Jürgens 357e4d94b9
Use LibreWolf-specific translations
See https://codeberg.org/librewolf/issues/issues/2043

Squashed commit of the following:

commit 81aac91633
Author: Ricky-Tigg <Ricky-Tigg@users.noreply.translate.codeberg.org>
Date:   Tue Oct 8 09:34:25 2024 +0000

    Translated using Weblate (Finnish)

    Currently translated at 100.0% (3 of 3 strings)

    Translation: LibreWolf/browser/translations
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browsertranslations/fi/

commit c6aee11b4e
Author: Ricky-Tigg <Ricky-Tigg@users.noreply.translate.codeberg.org>
Date:   Tue Oct 8 09:37:09 2024 +0000

    Translated using Weblate (Finnish)

    Currently translated at 100.0% (7 of 7 strings)

    Translation: LibreWolf/toolkit/branding/brandings
    Translate-URL: https://translate.codeberg.org/projects/librewolf/toolkitbrandingbrandings/fi/

commit c18e4cdd0e
Author: Ricky-Tigg <Ricky-Tigg@users.noreply.translate.codeberg.org>
Date:   Tue Oct 8 09:32:12 2024 +0000

    Added translation using Weblate (Finnish)

commit 20ea70ee26
Author: Ricky-Tigg <Ricky-Tigg@users.noreply.translate.codeberg.org>
Date:   Tue Oct 8 09:31:49 2024 +0000

    Added translation using Weblate (Finnish)

commit c98722de01
Author: Benny <Benny@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 19:23:30 2024 +0000

    Translated using Weblate (German)

    Currently translated at 14.0% (7 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/de/

commit 9ba6e88056
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 17:49:12 2024 +0200

    Fix l10n paths

commit cae2630523
Author: maltejur <maltejur@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 14:14:05 2024 +0000

    Translated using Weblate (German)

    Currently translated at 100.0% (7 of 7 strings)

    Translation: LibreWolf/toolkit/branding/brandings
    Translate-URL: https://translate.codeberg.org/projects/librewolf/toolkitbrandingbrandings/de/

commit 6e91dfdec2
Author: maltejur <maltejur@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 14:12:08 2024 +0000

    Translated using Weblate (German)

    Currently translated at 28.5% (2 of 7 strings)

    Translation: LibreWolf/toolkit/branding/brandings
    Translate-URL: https://translate.codeberg.org/projects/librewolf/toolkitbrandingbrandings/de/

commit 5230f7b9d6
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 16:13:13 2024 +0200

    Rename Firefox View

commit 1f74c5cf99
Author: maltejur <maltejur@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 14:11:46 2024 +0000

    Added translation using Weblate (German)

commit 65017ab267
Author: diivu <diivu@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 07:29:07 2024 +0000

    Translated using Weblate (Finnish)

    Currently translated at 88.0% (44 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/fi/

commit da88f487ac
Author: Benny <Benny@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 12:44:06 2024 +0000

    Translated using Weblate (German)

    Currently translated at 12.0% (6 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/de/

commit 8cc562f87a
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 15:58:48 2024 +0200

    Fix l10n folder structure

commit a287b0ff64
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 15:25:49 2024 +0200

    Move some patches to brandings.ftl

commit 66263ed412
Merge: 0aaa908 0fb44c4
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 14:37:18 2024 +0200

    Merge remote-tracking branch 'origin/main' into l10n

commit 0aaa90890f
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Oct 6 14:37:08 2024 +0200

    Fix appstrings.properties

commit 376b65bbb1
Author: diivu <diivu@users.noreply.translate.codeberg.org>
Date:   Sun Oct 6 07:24:56 2024 +0000

    Added translation using Weblate (Finnish)

commit 963c276a24
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sun Sep 29 14:45:36 2024 +0200

    Use wget in l10n script for consistency

commit d0e0ef0769
Author: kratos <kratos@users.noreply.translate.codeberg.org>
Date:   Fri Sep 27 14:01:32 2024 +0000

    Translated using Weblate (Hungarian)

    Currently translated at 100.0% (3 of 3 strings)

    Translation: LibreWolf/browser/translations
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browsertranslations/hu/

commit db529f8ce1
Author: kratos <kratos@users.noreply.translate.codeberg.org>
Date:   Fri Sep 27 14:01:01 2024 +0000

    Added translation using Weblate (Hungarian)

commit a9fb722578
Author: kratos <kratos@users.noreply.translate.codeberg.org>
Date:   Fri Sep 27 13:51:48 2024 +0000

    Translated using Weblate (Hungarian)

    Currently translated at 100.0% (50 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/hu/

commit a54b7cdb5e
Author: Umeaman <Umeaman@users.noreply.translate.codeberg.org>
Date:   Wed Sep 25 23:36:20 2024 +0000

    Translated using Weblate (Swedish)

    Currently translated at 10.0% (5 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/sv/

commit 555586291d
Author: Umeaman <Umeaman@users.noreply.translate.codeberg.org>
Date:   Wed Sep 25 23:36:02 2024 +0000

    Added translation using Weblate (Swedish)

commit 65662b49a5
Author: kratos <kratos@users.noreply.translate.codeberg.org>
Date:   Mon Sep 23 18:23:02 2024 +0000

    Translated using Weblate (Hungarian)

    Currently translated at 16.0% (8 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/hu/

commit 1460588363
Author: kratos <kratos@users.noreply.translate.codeberg.org>
Date:   Mon Sep 23 18:22:00 2024 +0000

    Added translation using Weblate (Hungarian)

commit 78667d9c9c
Author: maltejur <maltejur@users.noreply.translate.codeberg.org>
Date:   Thu Sep 19 15:54:14 2024 +0000

    Translated using Weblate (German)

    Currently translated at 10.0% (5 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences
    Translate-URL: https://translate.codeberg.org/projects/librewolf/browserpreferencespreferences/de/

commit dc948492ef
Author: Malte Juergens <maltejur@dismail.de>
Date:   Thu Sep 19 17:50:18 2024 +0200

    Remove appstrings.properties override

commit b92da6c9b6
Author: Malte Juergens <maltejur@dismail.de>
Date:   Thu Sep 19 17:49:49 2024 +0200

    Use dashes in language codes

commit b49b4b1661
Author: Malte Juergens <maltejur@dismail.de>
Date:   Thu Sep 19 17:42:01 2024 +0200

    Fix syntax error in old python version

commit eed271897f
Author: Malte Juergens <maltejur@dismail.de>
Date:   Wed Sep 18 01:44:57 2024 +0200

    Make lw translations work

commit f8c5b9e264
Author: Allan Nordhøy <epost@anotheragency.no>
Date:   Mon Sep 16 10:31:25 2024 +0000

    Translated using Weblate (Norwegian Bokmål)

    Currently translated at 100.0% (3 of 3 strings)

    Translation: LibreWolf/browser/translations.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browsertranslationsftl/nb_NO/

commit 4accda62a1
Author: Allan Nordhøy <epost@anotheragency.no>
Date:   Mon Sep 16 10:43:25 2024 +0000

    Translated using Weblate (German)

    Currently translated at 8.0% (4 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browserpreferencespreferencesftl/de/

commit e09583f951
Author: Allan Nordhøy <epost@anotheragency.no>
Date:   Mon Sep 16 10:43:41 2024 +0000

    Translated using Weblate (French)

    Currently translated at 98.0% (49 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browserpreferencespreferencesftl/fr/

commit 08bebb1a5c
Author: Allan Nordhøy <epost@anotheragency.no>
Date:   Mon Sep 16 10:43:41 2024 +0000

    Translated using Weblate (English (United States))

    Currently translated at 100.0% (50 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browserpreferencespreferencesftl/en_US/

commit b07795c146
Author: Allan Nordhøy <epost@anotheragency.no>
Date:   Sun Sep 15 11:59:46 2024 +0200

    Added translation using Weblate (Norwegian Bokmål)

commit c67532071f
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Fri Sep 13 23:02:08 2024 +0000

    Translated using Weblate (French)

    Currently translated at 66.6% (2 of 3 strings)

    Translation: LibreWolf/browser/translations.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browsertranslationsftl/fr/

commit 9b19745b7c
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sat Sep 14 01:01:08 2024 +0200

    Added translation using Weblate (French)

commit a51d08cc03
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sat Sep 14 00:59:14 2024 +0200

    Deleted translation using Weblate (French)

commit 8f5cdd20b5
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sat Sep 14 00:58:35 2024 +0200

    Added translation using Weblate (French)

commit 0a827abfd6
Author: Malte Juergens <maltejur@dismail.de>
Date:   Sat Sep 14 00:57:29 2024 +0200

    Move translations patches/fullpage-translations-customization.patch into own *.ftl file

commit dcd910c672
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Fri Sep 13 22:34:22 2024 +0000

    Translated using Weblate (German)

    Currently translated at 6.0% (3 of 50 strings)

    Translation: LibreWolf/browser/preferences/preferences.ftl
    Translate-URL: https://hosted.weblate.org/projects/librewolf/browserpreferencespreferencesftl/de/

commit 31851a6026
Author: Malte Jürgens <maltejur@dismail.de>
Date:   Sat Sep 14 00:33:16 2024 +0200

    Added translation using Weblate (German)

commit bc3d695711
Author: Malte Juergens <maltejur@dismail.de>
Date:   Fri Sep 13 23:21:29 2024 +0200

    Add French pref-pane Translations provided by @Acideburn

    Co-authored-by: Acideburn <Acideburn@noreply.codeberg.org>

commit 3072c26e4f
Author: Malte Juergens <maltejur@dismail.de>
Date:   Tue Sep 10 16:52:58 2024 +0200

    Allow translation of LW strings
2024-10-11 22:28:01 +02:00

212 lines
6.4 KiB
Python
Executable file

#!/usr/bin/env python3
#
# The script that patches the firefox source into the librewolf source.
#
import os
import sys
import optparse
import time
from pathlib import Path
from tempfile import TemporaryDirectory
#
# general functions, skip these, they are not that interesting
#
start_time = time.time()
parser = optparse.OptionParser()
parser.add_option('-n', '--no-execute', dest='no_execute', default=False, action="store_true")
parser.add_option('-P', '--no-settings-pane', dest='settings_pane', default=True, action="store_false")
options, args = parser.parse_args()
def script_exit(statuscode):
if (time.time() - start_time) > 60:
# print elapsed time
elapsed = time.strftime("%H:%M:%S", time.gmtime(time.time() - start_time))
print("\n\aElapsed time: {elapsed}")
sys.stdout.flush()
sys.exit(statuscode)
def exec(cmd, exit_on_fail = True, do_print = True):
if cmd != '':
if do_print:
print(cmd)
sys.stdout.flush()
if not options.no_execute:
retval = os.system(cmd)
if retval != 0 and exit_on_fail:
print("fatal error: command '{}' failed".format(cmd))
sys.stdout.flush()
script_exit(1)
return retval
return None
def patch(patchfile):
cmd = "patch -p1 -i {}".format(patchfile)
print("\n*** -> {}".format(cmd))
sys.stdout.flush()
if not options.no_execute:
retval = os.system(cmd)
if retval != 0:
print("fatal error: patch '{}' failed".format(patchfile))
sys.stdout.flush()
script_exit(1)
def enter_srcdir(_dir = None):
if _dir == None:
dir = "librewolf-{}-{}".format(version, release)
else:
dir = _dir
print("cd {}".format(dir))
sys.stdout.flush()
if not options.no_execute:
try:
os.chdir(dir)
except:
print("fatal error: can't change to '{}' folder.".format(dir))
sys.stdout.flush()
script_exit(1)
def leave_srcdir():
print("cd ..")
sys.stdout.flush()
if not options.no_execute:
os.chdir("..")
#
# This is the only interesting function in this script
#
def librewolf_patches():
enter_srcdir()
# create the right mozconfig file..
exec('cp -v ../assets/mozconfig.new mozconfig')
# copy branding files..
exec("cp -r ../themes/browser .")
# copy the right search-config.json file
exec('cp -v ../assets/search-config.json services/settings/dumps/main/search-config.json')
# read lines of .txt file into 'patches'
with open('../assets/patches.txt'.format(version), "r") as f:
for line in f.readlines():
patch('../'+line)
# apply xmas.patch seperately because not all builders use this repo the same way, and
# we don't want to disturbe those workflows.
patch('../patches/xmas.patch')
# vs_pack.py issue... should be temporary
exec('cp -v ../patches/pack_vs.py build/vs/')
#
# Apply most recent `settings` repository files.
#
exec('mkdir -p lw')
enter_srcdir('lw')
exec('cp -v ../../settings/librewolf.cfg .')
exec('cp -v ../../settings/distribution/policies.json .')
exec('cp -v ../../settings/defaults/pref/local-settings.js .')
leave_srcdir();
#
# pref-pane patches
#
# 1) patch it in
patch('../patches/pref-pane/pref-pane-small.patch')
# 2) new files
exec('cp ../patches/pref-pane/category-librewolf.svg browser/themes/shared/preferences/category-librewolf.svg')
exec('cp ../patches/pref-pane/librewolf.css browser/themes/shared/preferences/librewolf.css')
exec('cp ../patches/pref-pane/librewolf.inc.xhtml browser/components/preferences/librewolf.inc.xhtml')
exec('cp ../patches/pref-pane/librewolf.js browser/components/preferences/librewolf.js')
# provide a script that fetches and bootstraps Nightly and some mozconfigs
exec('cp -v ../scripts/mozfetch.sh lw/')
exec('cp -v ../assets/mozconfig.new ../assets/mozconfig.new.without-bootstrap ../scripts/setup-wasi-linux.sh lw/')
# override the firefox version
for file in ["browser/config/version.txt", "browser/config/version_display.txt"]:
with open(file, "w") as f:
f.write("{}-{}".format(version,release))
print("-> Downloading locales from https://github.com/mozilla-l10n/firefox-l10n")
with TemporaryDirectory() as tmpdir:
exec(f"wget -qO {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 lw/l10n")
print("-> Patching appstrings.properties")
# Why is "Firefox" hardcoded there???
exec("find . -path '*/appstrings.properties' -exec sed -i s/Firefox/LibreWolf/ {} \;")
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)
if rel_path.parts[0] == "en-US":
target_path = Path(
rel_path.parts[1],
"locales", "en-US",
*rel_path.parts[1:]
)
else:
target_path = Path(
"lw", "l10n",
*rel_path.parts[0:2],
*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()
#
# Main functionality in this script.. which is to call librewolf_patches()
#
if len(args) != 2:
sys.stderr.write('error: please specify version and release of librewolf source')
sys.exit(1)
version = args[0]
release = args[1]
srcdir = "librewolf-{}-{}".format(version, release)
if not os.path.exists(srcdir + '/configure.py'):
sys.stderr.write('error: folder doesn\'t look like a Firefox folder.')
sys.exit(1)
librewolf_patches()
sys.exit(0) # ensure 0 exit code