Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Heptazhou committed Jan 18, 2025
1 parent a5d96f6 commit 03e7b9b
Show file tree
Hide file tree
Showing 23 changed files with 1,206 additions and 513 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

/*/pkg/
/*/src/
Manifest-v*.toml
Manifest.toml
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"[javascript]": { "prettier.semi": true },
"copyrightInserter.useLineComment": true,
"files.associations": { "mozconfig": "shellscript" }
}
6 changes: 6 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
Exts = "0b12d779-4123-4875-9d6c-e33c2e29e2c9"

[compat]
Exts = "≥ 0.2.7"
julia = "≥ 1.9"
30 changes: 12 additions & 18 deletions Source/diff.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021-2024 Heptazhou <[email protected]>
# Copyright (C) 2021-2025 Heptazhou <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -14,23 +14,17 @@

include("base_func.jl")

try
cd(@__DIR__) do
diff = "git diff --patch-with-stat --minimal"
v = "v$(VER.major)"
cd("../../Firefox")
sh("$diff $(v) HEAD~4 > $(v).patch")
sh("$diff HEAD~4 HEAD~3 > font.patch")
sh("$diff HEAD~3 HEAD~2 > crlf.patch")
sh("$diff HEAD~1 HEAD~0 > typo.patch")
for f readdir()
g = "$(@__DIR__)/" * f
endswith(f, ".patch") && @info basename(mv(f, g, force = true))
end
cd(@__DIR__) do
diff = "git diff --patch-with-stat --minimal"
ver = "v$(VER.major)"
cd("../../Firefox")
sh("$diff $ver~0 HEAD~5 > $ver.patch")
sh("$diff HEAD~5 HEAD~4 > font.patch")
sh("$diff HEAD~4 HEAD~3 > crlf.patch")
sh("$diff HEAD~1 HEAD~0 > typo.patch")
for f readdir()
g = stdpath(@__DIR__, f)
endswith(f, ".patch") && @info basename(mv(f, g, force = true))
end
catch e
@info e
end
isempty(ARGS) || exit()
pause(up = 1)

2 changes: 1 addition & 1 deletion Source/font.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index c0a4700dd00b..f3c6ca49529a 100644
index 6c1da6fa130b..4214f5d76aff 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2164,13 +2164,13 @@ pref("font.size.monospace.x-math", 13);
Expand Down
81 changes: 81 additions & 0 deletions Source/l10n.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright (C) 2022-2025 Heptazhou <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

include("base_func.jl")

function build()
dir = L10N_PKG_DIR
tar = L10N_PKG_TAR
@time cd(SRC) do
sh("tar Ifc \"$TAR_ZST_18\" $tar $dir")
for h ("sha256", "sha3-512")
sh("$(h)sum $tar | tee $tar.$(h)")
end
end
for f filter!(startswith(tar), readdir(SRC))
@info mv(SRC / f, PKG / f, force = true)
end
end

function clean()
@time cd(SRC) do
for d filter!(isdir, readdir())
contains(d, "l10n") || continue
@info d
rm(d, recursive = true)
end
end
end

function fetch()
@time cd(SRC) do
curl(L10N_SRC_URL, L10N_SRC_TAR)
end
end

function patch()
dir = SRC / L10N_PKG_DIR
sh("julia locale.jl $dir")
end

function unpack()
tar = L10N_SRC_TAR
src = L10N_SRC_DIR
@time cd(SRC) do
dst = L10N_PKG_DIR
isdir(dst) && return dst
isdir(src) || sh("tar fx $tar")
mv(src, dst, force = true)
end
end

if abspath(PROGRAM_FILE) == @__FILE__
mkpath(PKG)
mkpath(SRC)
args = Symbol.(ARGS)
@assert all(([
:build
:clean
:fetch
:patch
:unpack
]), args)
for f args
@info f
@eval $f()
end
end

# time julia l10n.jl fetch unpack patch build clean

84 changes: 59 additions & 25 deletions Source/locale.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022-2024 Heptazhou <[email protected]>
# Copyright (C) 2022-2025 Heptazhou <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -12,10 +12,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# [compat]
# julia = "≥ 1.6"
include("base_func.jl")

const lc = cd(@__DIR__) do
f = "../../Firefox/browser/locales/shipped-locales"
isfile(f) && cp(f, basename(f), force = true)
readlines("shipped-locales")
end

Expand All @@ -35,6 +36,8 @@ const rs =
"^default-bookmarks-nightly-"
"^DrawWindowCanvasRenderingContext2DWarning"
"^e10s\\.accessibilityNotice\\.jawsMessage"
"^ion-enroll-"
"^ion-summary"
"^ManufacturerID"
"^migration-wizard-migrator-display-name-"
"^MozillaMaintenanceDescription"
Expand All @@ -56,41 +59,72 @@ const rs =
"^-mozmonitor"
"^-profiler"
"^-relay"
"^-secure-proxy"
"^-send"
"^-translations"
] .* "-brand-"
] .|> Regex

@time foreach(ARGS) do (dir)
endswith(r"\bl10n")(dir) && cd(dir) do
function patch(x; keep = false)
dir = mkpath(x) / ""
keep || endswith(r"\bl10n(-\w+)?/")(dir) && cd(dir) do
for x readdir()
x [lc; ".git"] || rm(x, recursive = true)
end
end
for (prefix, ds, fs) walkdir(dir, topdown = false)
occursin(prefix)(r"\.git\b") && continue
for (prefix, ds, fs) walkdir(dir, topdown = keep)
@skip_ds prefix
endswith(prefix, "/browser/branding/") || continue
print("\r\e[2K", prefix)
cd(prefix) do
for d ds
if basename(prefix) "branding" && d "official"
mv(d, "snowfox", force = true)
end
end
for f fs
if endswith(".ftl")(f) || endswith(".ini")(f) ||
endswith(".properties")(f)
v = readlines(f)
replace!(v) do s
any(occursin(s), rs) && return s
# = { DATETIME(\$dateObj, dateStyle: "short", timeStyle: "medium") }
s = replace(s, r"^[^#]*?=.*?\K\{.*?(\$dateObj)\b.*?\}" => s"{ \1 }")
s = replace(s, r"^[^#]*?=.*?\K\b(Mozilla +)?Firefox\b" => "Snowfox")
s = replace(s, r"^[^#]*?=.*?\K\bMozilla\b" => "Snowfox")
return s
end
write(f, join(v, "\n"), "\n")
d = "official"
d′ = "snowfox"
isdir(d) || return
ps = [
"brand.ftl"
"brand.properties"
"locales/jar.mn"
"locales/moz.build"
]
_ = keep ? for (p, p′) eachrow([d d′] ./ ps)
ispath(p) ? mkpath(dirname(p′)) : continue
cp(p, p′, force = true)
end :
mv(d, d′, force = true)
end
end
for (prefix, ds, fs) walkdir(dir, topdown = true)
@skip_ds prefix
contains(prefix, r"/browser/branding/(?!snowfox|$)") && continue
print("\r\e[2K", prefix)
for f fs
if endswith(".dtd")(f) || endswith(".ftl")(f) ||
endswith(".ini")(f) || endswith(".properties")(f)
x = f ("appstrings", "dom") .* ".properties"
v = readlines(prefix / f, keep = true)
_ = replace!(v) do s
any(occursin(s), rs) && return s
# = { DATETIME(\$dateObj, dateStyle: "short", timeStyle: "medium") }
s = replace(s, r"^[^#]*?=.*?\K\{.*?(\$dateObj)\b.*?\}" => s"{ \1 }")
s = replace(s, r"^[^#]*?=.*?\K\b(Mozilla +)?Firefox\b" => "Snowfox")
x ? expands(s) : (s)
end
write(prefix / f, join(v))
end
end
end
print("\r\e[2K")
end

const keep = any((ARGS), ("-k", "--keep"))

if abspath(PROGRAM_FILE) == @__FILE__
@time foreach((ARGS)) do arg
startswith(arg, r"--?\w") && return
patch(arg; keep)
end
end

# time julia locale.jl ../../Firefox -k
# time julia locale.jl ../../firefox-l10n-source ../../firefox-l10n/zh-CN

Loading

0 comments on commit 03e7b9b

Please sign in to comment.