[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] Improve how we import, bundle and register translations.



commit 951b654f29868d8b52c1c8a0713346678a64fde6
Author: Tails developers <amnesia@xxxxxxxx>
Date:   Wed Mar 12 15:10:05 2014 +0100

    Improve how we import, bundle and register translations.
    
    Previously chrome.manifest defined locales for pretty much every
    existing locale. Many of these were out-of-date (lacking entities,
    which results in fatal XUL errors) or completely absent (also fatal).
    
    Instead of maintaining a static list of which locales to register we
    generate it programatically, making sure that only those that seem
    complete are included. We also make sure to register "en-US" since
    it's the hardcoded fallback for unregistered locales. Note that it's
    currently called "en" in the Transifex translation repos.
    
    The BUNDLE_LOCALES environment variable can be set to specify a list
    of which locales to bundle ("en-US" is always implied). If it's empty
    we optimistically try to include all locales. For this reason
    import-translations.sh imports all translations from Transifex, and
    it's important to run it before packaging since up-to-date
    translations are necessary to avoid the issues mentioned above.
---
 Makefile                            |   43 +++++++++--
 chrome.manifest.in                  |   16 +++++
 localization/import-translations.sh |   41 +++++------
 src/chrome.manifest                 |  136 -----------------------------------
 4 files changed, 73 insertions(+), 163 deletions(-)

diff --git a/Makefile b/Makefile
index 3d3a857..b698f4e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ VERSION:=`grep em:version src/install.rdf | sed -e 's/[<>]/	/g' | cut -f3`
 XPI_NAME:=$(shell echo "$(EXT_NAME)-$(VERSION).xpi")
 STANDALONE_NAME=$(EXT_NAME)-standalone
 STANDALONE_TARBALL=$(shell echo "$(STANDALONE_NAME)-$(VERSION).tar.gz")
+REQUIRED_TRANSLATION_FILES=$(shell ls -1 src/chrome/locale/en/)
 
 AVAIL_TARGETS=help package standalone clean
 
@@ -25,15 +26,49 @@ help:
 
 pkg-prepare:	clean
 	@mkdir -p pkg
+	$(eval TMP="$(shell mktemp -d "/tmp/$(EXT_NAME).XXXXXX")")
+	@cp -a "src" "$(TMP)/$(EXT_NAME)"
+	@cp -a chrome.manifest.in "$(TMP)/$(EXT_NAME)"/chrome.manifest
+	@mv "$(TMP)/$(EXT_NAME)"/chrome/locale/en \
+	    "$(TMP)/$(EXT_NAME)"/chrome/locale/en-US
+	@for d in "$(TMP)/$(EXT_NAME)"/chrome/locale/*; do \
+	   if [ "`basename "$${d}"`" = "en-US" ]; then \
+	     continue; \
+	   fi; \
+	   for f in $(REQUIRED_TRANSLATION_FILES); do \
+	     if [ ! -e "$${d}/$${f}" ] || \
+	        ( \
+	          [ -n "$(BUNDLE_LOCALES)" ] && \
+	          ! echo $(BUNDLE_LOCALES) | grep -qw `basename "$${d}"` \
+	        ); then \
+	       rm -rf "$${d}"; \
+	       break; \
+	     fi \
+	   done \
+	 done
+	@for l in $(BUNDLE_LOCALES); do \
+	   if [ ! -d "$(TMP)/$(EXT_NAME)"/chrome/locale/"$${l}" ]; then \
+	     echo "Requested locale '$${l}' is missing or incomplete" >&2; \
+	     exit 1; \
+	   fi \
+	 done
+	@for d in "$(TMP)/$(EXT_NAME)"/chrome/locale/*; do \
+	   locale="`basename $${d}`"; \
+	   echo "locale torlauncher $${locale} chrome/locale/$${locale}/" >> \
+	        "$(TMP)/$(EXT_NAME)"/chrome.manifest; \
+	 done
 
 package:	pkg-prepare
-	@(cd src; $(ZIP) -X9r "../pkg/$(XPI_NAME)" ./ -x "*.diff")
+	@( \
+	   CURDIR="$(shell pwd)"; \
+	   cd "$(TMP)/$(EXT_NAME)"; \
+	   $(ZIP) -X9r "$(CURDIR)/pkg/$(XPI_NAME)" ./ -x "*.diff" \
+	 )
+	@rm -rf "$(TMP)"
 	@echo "Created package pkg/$(XPI_NAME)"
 
 standalone:	pkg-prepare
-	$(eval TMP="$(shell mktemp -d "/tmp/$(STANDALONE_NAME).XXXXXX")")
-	@mkdir -p "$(TMP)/$(STANDALONE_NAME)"
-	@cp -a "src/"* "$(TMP)/$(STANDALONE_NAME)"
+	@mv "$(TMP)/$(EXT_NAME)" "$(TMP)/$(STANDALONE_NAME)"
 	@cp application.ini.in "$(TMP)/$(STANDALONE_NAME)/application.ini"
 	@sed -i	-e "s/__VERSION__/$(VERSION)/" \
 		-e "s/__DATE__/`date '+%Y%m%d'`/" \
diff --git a/chrome.manifest.in b/chrome.manifest.in
new file mode 100644
index 0000000..a869569
--- /dev/null
+++ b/chrome.manifest.in
@@ -0,0 +1,16 @@
+### Copyright (c) 2013, The Tor Project, Inc.
+### See LICENSE for licensing information.
+
+content torlauncher chrome/content/
+
+skin torlauncher classic/1.0 chrome/skin/
+
+resource torlauncher ./
+
+# Firefox 4-style component registration
+component {4F476361-23FB-43EF-A427-B36A14D3208E} components/tl-protocol.js
+contract @torproject.org/torlauncher-protocol-service;1 {4F476361-23FB-43EF-A427-B36A14D3208E}
+
+component {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1} components/tl-process.js
+contract @torproject.org/torlauncher-process-service;1 {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}
+category profile-after-change TorProcessService @torproject.org/torlauncher-process-service;1
diff --git a/localization/import-translations.sh b/localization/import-translations.sh
index 32ea177..0c81aa6 100755
--- a/localization/import-translations.sh
+++ b/localization/import-translations.sh
@@ -1,13 +1,10 @@
 #!/bin/sh
 
-BUNDLE_LOCALES="ar de es fa fr it ko nl pl pt ru tr vi zh-CN"
-
-# XXX: Basque (eu) by request in #10687.
-# This is not used for official builds, but should remain 
-# so Basque XPIs can be build independently. We can do
-# this for other languages too, if anyone requests this
-# and translations are available.
-BUNDLE_LOCALES="$BUNDLE_LOCALES eu ja sv"
+TRANSLATION_BRANCHES="
+tor-launcher-network-settings
+tor-launcher-progress
+tor-launcher-properties
+"
 
 if [ -d translation ];
 then
@@ -19,20 +16,18 @@ else
 fi
 
 cd translation
-for i in $BUNDLE_LOCALES
+for branch in ${TRANSLATION_BRANCHES}
 do
-  UL="`echo $i|tr - _`"
-  mkdir -p ../../src/chrome/locale/$i/
-
-  git checkout tor-launcher-network-settings
-  git merge origin/tor-launcher-network-settings
-  cp $UL/network-settings.dtd ../../src/chrome/locale/$i/
-
-  git checkout tor-launcher-progress
-  git merge origin/tor-launcher-progress
-  cp $UL/progress.dtd ../../src/chrome/locale/$i/
-
-  git checkout tor-launcher-properties
-  git merge origin/tor-launcher-properties
-  cp $UL/torlauncher.properties ../../src/chrome/locale/$i/
+  git checkout ${branch}
+  git merge origin/${branch}
+  for locale in *
+  do
+    if [ ! -d "${locale}" ]
+    then
+      continue
+    fi
+    target="../../src/chrome/locale/$(echo "${locale}" | tr _ -)"
+    mkdir -p "${target}"
+    cp -f "${locale}"/* "${target}"/
+  done
 done
diff --git a/src/chrome.manifest b/src/chrome.manifest
deleted file mode 100644
index 786bae8..0000000
--- a/src/chrome.manifest
+++ /dev/null
@@ -1,136 +0,0 @@
-### Copyright (c) 2013, The Tor Project, Inc.
-### See LICENSE for licensing information.
-
-content torlauncher chrome/content/
-
-locale torlauncher af chrome/locale/af/
-locale torlauncher ak chrome/locale/ak/
-locale torlauncher am chrome/locale/am/
-locale torlauncher ar chrome/locale/ar/
-locale torlauncher arn chrome/locale/arn/
-locale torlauncher ast chrome/locale/ast/
-locale torlauncher az chrome/locale/az/
-locale torlauncher be chrome/locale/be/
-locale torlauncher bg chrome/locale/bg/
-locale torlauncher bms chrome/locale/bms/
-locale torlauncher bn chrome/locale/bn/
-locale torlauncher bn-IN chrome/locale/bn-IN/
-locale torlauncher bo chrome/locale/bo/
-locale torlauncher br chrome/locale/br/
-locale torlauncher bs chrome/locale/bs/
-locale torlauncher ca chrome/locale/ca/
-locale torlauncher cs chrome/locale/cs/
-locale torlauncher csb chrome/locale/csb/
-locale torlauncher cy chrome/locale/cy/
-locale torlauncher da chrome/locale/da/
-locale torlauncher de chrome/locale/de/
-locale torlauncher dz chrome/locale/dz/
-locale torlauncher el chrome/locale/el/
-locale torlauncher en chrome/locale/en/
-locale torlauncher eo chrome/locale/eo/
-locale torlauncher es chrome/locale/es/
-locale torlauncher et chrome/locale/et/
-locale torlauncher eu chrome/locale/eu/
-locale torlauncher fa chrome/locale/fa/
-locale torlauncher fi chrome/locale/fi/
-locale torlauncher fil chrome/locale/fil/
-locale torlauncher fo chrome/locale/fo/
-locale torlauncher fr chrome/locale/fr/
-locale torlauncher fur chrome/locale/fur/
-locale torlauncher fy chrome/locale/fy/
-locale torlauncher ga chrome/locale/ga/
-locale torlauncher gl chrome/locale/gl/
-locale torlauncher gu chrome/locale/gu/
-locale torlauncher gun chrome/locale/gun/
-locale torlauncher ha chrome/locale/ha/
-locale torlauncher he chrome/locale/he/
-locale torlauncher hi chrome/locale/hi/
-locale torlauncher hr chrome/locale/hr/
-locale torlauncher ht chrome/locale/ht/
-locale torlauncher hu chrome/locale/hu/
-locale torlauncher hy chrome/locale/hy/
-locale torlauncher id chrome/locale/id/
-locale torlauncher is chrome/locale/is/
-locale torlauncher it chrome/locale/it/
-locale torlauncher ja chrome/locale/ja/
-locale torlauncher jv chrome/locale/jv/
-locale torlauncher ka chrome/locale/ka/
-locale torlauncher km chrome/locale/km/
-locale torlauncher kn chrome/locale/kn/
-locale torlauncher ko chrome/locale/ko/
-locale torlauncher ku chrome/locale/ku/
-locale torlauncher kw chrome/locale/kw/
-locale torlauncher ky chrome/locale/ky/
-locale torlauncher lb chrome/locale/lb/
-locale torlauncher lg chrome/locale/lg/
-locale torlauncher ln chrome/locale/ln/
-locale torlauncher lo chrome/locale/lo/
-locale torlauncher lt chrome/locale/lt/
-locale torlauncher lv chrome/locale/lv/
-locale torlauncher mg chrome/locale/mg/
-locale torlauncher mi chrome/locale/mi/
-locale torlauncher mk chrome/locale/mk/
-locale torlauncher ml chrome/locale/ml/
-locale torlauncher mn chrome/locale/mn/
-locale torlauncher mr chrome/locale/mr/
-locale torlauncher ms chrome/locale/ms/
-locale torlauncher mt chrome/locale/mt/
-locale torlauncher my chrome/locale/my/
-locale torlauncher nah chrome/locale/nah/
-locale torlauncher nap chrome/locale/nap/
-locale torlauncher nb chrome/locale/nb/
-locale torlauncher ne chrome/locale/ne/
-locale torlauncher nl chrome/locale/nl/
-locale torlauncher nn chrome/locale/nn/
-locale torlauncher nso chrome/locale/nso/
-locale torlauncher oc chrome/locale/oc/
-locale torlauncher or chrome/locale/or/
-locale torlauncher pa chrome/locale/pa/
-locale torlauncher pap chrome/locale/pap/
-locale torlauncher pl chrome/locale/pl/
-locale torlauncher pms chrome/locale/pms/
-locale torlauncher ps chrome/locale/ps/
-locale torlauncher pt chrome/locale/pt/
-locale torlauncher pt-BR chrome/locale/pt-BR/
-locale torlauncher ro chrome/locale/ro/
-locale torlauncher ru chrome/locale/ru/
-locale torlauncher sco chrome/locale/sco/
-locale torlauncher sk chrome/locale/sk/
-locale torlauncher sl chrome/locale/sl/
-locale torlauncher so chrome/locale/so/
-locale torlauncher son chrome/locale/son/
-locale torlauncher sq chrome/locale/sq/
-locale torlauncher sr chrome/locale/sr/
-locale torlauncher st chrome/locale/st/
-locale torlauncher su chrome/locale/su/
-locale torlauncher sv chrome/locale/sv/
-locale torlauncher sw chrome/locale/sw/
-locale torlauncher ta chrome/locale/ta/
-locale torlauncher te chrome/locale/te/
-locale torlauncher tg chrome/locale/tg/
-locale torlauncher th chrome/locale/th/
-locale torlauncher ti chrome/locale/ti/
-locale torlauncher tk chrome/locale/tk/
-locale torlauncher tr chrome/locale/tr/
-locale torlauncher uk chrome/locale/uk/
-locale torlauncher ur chrome/locale/ur/
-locale torlauncher ve chrome/locale/ve/
-locale torlauncher vi chrome/locale/vi/
-locale torlauncher wa chrome/locale/wa/
-locale torlauncher wo chrome/locale/wo/
-locale torlauncher zh-CN chrome/locale/zh-CN/
-locale torlauncher zh-HK chrome/locale/zh-HK/
-locale torlauncher zh-TW chrome/locale/zh-TW/
-locale torlauncher zu chrome/locale/zu/
-
-skin torlauncher classic/1.0 chrome/skin/
-
-resource torlauncher ./
-
-# Firefox 4-style component registration
-component {4F476361-23FB-43EF-A427-B36A14D3208E} components/tl-protocol.js
-contract @torproject.org/torlauncher-protocol-service;1 {4F476361-23FB-43EF-A427-B36A14D3208E}
-
-component {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1} components/tl-process.js
-contract @torproject.org/torlauncher-process-service;1 {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}
-category profile-after-change TorProcessService @torproject.org/torlauncher-process-service;1



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits