-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,206 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
/*/pkg/ | ||
/*/src/ | ||
Manifest-v*.toml | ||
Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
||
|
@@ -35,6 +36,8 @@ const rs = | |
"^default-bookmarks-nightly-" | ||
"^DrawWindowCanvasRenderingContext2DWarning" | ||
"^e10s\\.accessibilityNotice\\.jawsMessage" | ||
"^ion-enroll-" | ||
"^ion-summary" | ||
"^ManufacturerID" | ||
"^migration-wizard-migrator-display-name-" | ||
"^MozillaMaintenanceDescription" | ||
|
@@ -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 | ||
|
Oops, something went wrong.