diff options
author | Clément Lassieur <clement@lassieur.org> | 2024-01-09 00:43:11 +0100 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2024-01-21 01:17:51 +0100 |
commit | 0ef8afe1e1e48f9a5e0b695d4cc41ff73dfba917 (patch) | |
tree | 61bcf84f7459c260b794e59d2334ae2e74fef8c1 /gnu/packages/tor.scm | |
parent | 8ca35ca44f177dfd54d62b18748819f0f08e7828 (diff) |
gnu: torbrowser: Add support for language localisation.
* gnu/packages/gnuzilla.scm (all-mozilla-locales): Export it.
* gnu/packages/tor.scm (%torbrowser-locales, translation-base-browser,
translation-tor-browser): New variables.
(torbrowser)[arguments]: In ‘setenv’ phase, set MOZ_CHROME_MULTILOCALE. Add
‘copy-firefox-locales’, ‘copy-basebrowser-locales’, ‘copy-torbrowser-locales’
and ‘build-locales’ phases.
Change-Id: Ia5b28fa5d885f24140893dc270e57e83b0250c67
Diffstat (limited to 'gnu/packages/tor.scm')
-rw-r--r-- | gnu/packages/tor.scm | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm index ce84aa0726..56e9e5b5c9 100644 --- a/gnu/packages/tor.scm +++ b/gnu/packages/tor.scm @@ -503,6 +503,36 @@ up with TOR on your system anymore.") ;; "src-firefox-tor-browser-". (define %torbrowser-firefox-version "115.6.0esr-13.0-1-build2") +;; Use the list in tor-browser-build/rbm.conf. +(define %torbrowser-locales + '("ar" "ca" "cs" "da" "de" "el" "es-ES" "fa" "fi" "fr" "ga-IE" "he" "hu" + "id" "is" "it" "ja" "ka" "ko" "lt" "mk" "ms" "my" "nb-NO" "nl" "pl" + "pt-BR" "ro" "ru" "sq" "sv-SE" "th" "tr" "uk" "vi" "zh-CN" "zh-TW")) + +;; See tor-browser-build/projects/translation/config. +(define translation-base-browser + (origin + (method git-fetch) + (uri (git-reference + (url "https://gitlab.torproject.org/tpo/translation.git") + (commit "5490489a8d356a44d792300b4dfddba792d10f2e"))) + (file-name "translation-base-browser") + (sha256 + (base32 + "1knxary2zp2705xzzs76gpy37ri69yp32ajpmpxki3z5hp7mla7q")))) + +;; See tor-browser-build/projects/translation/config. +(define translation-tor-browser + (origin + (method git-fetch) + (uri (git-reference + (url "https://gitlab.torproject.org/tpo/translation.git") + (commit "273592eca488ca3bf535d3789b1130fd1970f09a"))) + (file-name "translation-tor-browser") + (sha256 + (base32 + "1mjqk4ljsjlwpqz29dnkhcvj24b75k2waicp0h07sll8qzv3rzz6")))) + (define torbrowser-assets ;; This is a prebuilt Torbrowser from which we take the assets we need. (package @@ -581,6 +611,8 @@ Browser.") ;; $HOME/.mozbuild). (setenv "MOZBUILD_STATE_PATH" (in-vicinity (getcwd) ".mozbuild")) + (setenv "MOZ_CHROME_MULTILOCALE" + (string-join '#$%torbrowser-locales)) ;; Make build reproducible. (setenv "MOZ_BUILD_DATE" #$%moz-build-date))) (add-before 'configure 'mozconfig @@ -594,6 +626,79 @@ Browser.") (replace 'configure (lambda _ (invoke "./mach" "configure"))) + ;; See tor-browser-build/projects/firefox/build. + (add-before 'configure 'copy-firefox-locales + (lambda _ + (let ((l10ncentral ".mozbuild/l10n-central")) + (mkdir-p l10ncentral) + (for-each + (lambda (lang) + (copy-recursively (find (lambda (path) + (string-suffix? lang path)) + '#$all-mozilla-locales) + (in-vicinity l10ncentral lang))) + '#$%torbrowser-locales)))) + (add-after 'copy-firefox-locales 'copy-basebrowser-locales + (lambda _ + (let ((l10ncentral ".mozbuild/l10n-central")) + ;; Temporary copy so that we can use ‘mv’ to mimic + ;; tor-browser-build/projects/firefox/build. + (copy-recursively #$translation-base-browser + "translation-base-browser") + (for-each + (lambda (lang) + (system + (format + #f (string-join + '("mv" + "translation-base-browser/~a/base-browser.ftl" + "~a/~a/browser/browser/")) + lang l10ncentral lang)) + (system + (format + #f (string-join + '("mv" + "translation-base-browser/~a/*" + "~a/~a/browser/chrome/browser/")) + lang l10ncentral lang))) + '#$%torbrowser-locales)))) + (add-after 'copy-basebrowser-locales 'copy-torbrowser-locales + (lambda _ + (let ((l10ncentral ".mozbuild/l10n-central")) + ;; Temporary copy so that we can use ‘mv’ to mimic + ;; tor-browser-build/projects/firefox/build. + (copy-recursively #$translation-tor-browser + "translation-tor-browser") + (for-each + (lambda (lang) + (system + (format + #f (string-join + '("mv" + "translation-tor-browser/~a/tor-browser.ftl" + "~a/~a/browser/browser/")) + lang l10ncentral lang)) + (system + (format + #f (string-join + '("mv" + "translation-tor-browser/~a/cryptoSafetyPrompt.properties" + "~a/~a/browser/chrome/browser/")) + lang l10ncentral lang)) + (system + (format + #f (string-join + '("mv" + "translation-tor-browser/~a" + "toolkit/torbutton/chrome/locale/")) + lang)) + (let ((port (open-file "toolkit/torbutton/jar.mn" "a"))) + (format port "% locale torbutton ~a %locale/~a/~%" + lang lang) + (format port " locale/~a/ (chrome/locale/~a/*)~%" + lang lang) + (close port))) + '#$%torbrowser-locales)))) (add-before 'build 'fix-addons-placeholder (lambda _ (substitute* @@ -607,6 +712,11 @@ Browser.") "#include ../../../tools/torbrowser/bridges.js" port) (newline port) (close port)))) + ;; See tor-browser-build/projects/firefox/build. + (add-after 'build 'build-locales + (lambda _ + (system (string-join '("./mach package-multi-locale --locales" + "en-US $MOZ_CHROME_MULTILOCALE"))))) (add-after 'install 'deploy-assets (lambda* (#:key inputs #:allow-other-keys) (let ((lib (in-vicinity #$output "lib/torbrowser")) |