3 # This var comes from the TBB locale list.
4 # XXX: Find some way to keep this, tor-launcher, and Tor Browser in sync
5 BUNDLE_LOCALES
="ar ca cs da de el es-AR es-ES fa fr ga-IE he hu id is it ja ka ko lt nb-NO mk ms my nl pl pt-BR ro ru sv-SE th tr uk vi zh-CN zh-TW"
7 # XXX: Basque (eu) by request in #10687.
8 # This is not used for official builds, but should remain so Basque XPIs can be
9 # built independently. We can do that for other languages too, if anyone
10 # requests it and translations are available.
11 # XXX: Adding bn-BD as well as we don't ship that locale ourselves due to bug
12 # 26498 and #29257. Others might want to fix, build, and use it, though.
13 BUNDLE_LOCALES
="$BUNDLE_LOCALES eu bn-BD"
15 LOCALE_DIR
=.
/chrome
/locale
17 # FILEMAP is an array of "localeFile:translationBranch" strings.
18 FILEMAP
=( "aboutDialog.dtd:torbutton-aboutdialogdtd"
19 "aboutTor.dtd:abouttor-homepage"
20 "aboutTBUpdate.dtd:torbutton-abouttbupdatedtd"
21 "brand.dtd:torbutton-branddtd"
22 "brand.properties:torbutton-brandproperties"
23 "browserOnboarding.properties:torbutton-browseronboardingproperties"
24 "torbutton.dtd:torbutton-torbuttondtd"
25 "torbutton.properties:torbutton-torbuttonproperties"
26 "network-settings.dtd:tor-launcher-network-settings"
27 "torlauncher.properties:tor-launcher-properties"
30 # Verify that the FILEMAP contains an entry for each Torbutton file.
32 for DEST_PATH
in $LOCALE_DIR/en-US
/*.dtd
$LOCALE_DIR/en-US
/*.properties
;
35 DEST_FILE
=${DEST_PATH##*/}
36 for KEYVAL
in "${FILEMAP[@]}";
39 if [ $FILE = $DEST_FILE ];
46 if [ $IS_FILE_IN_MAP -eq 0 -a $DEST_FILE != "onboarding.properties" ];
48 echo "Please add $DEST_FILE to FILEMAP." 1>&2
53 if [ $FILES_ARE_MISSING -ne 0 ];
58 # Clone or update our translation repo.
59 if [ -d translation
];
65 git clone https
://gitlab.torproject.org
/tpo
/translation.git
68 # Update each translated file for each locale.
70 echo "Locales: $BUNDLE_LOCALES"
72 for KEYVAL
in "${FILEMAP[@]}"; do
73 DEST_FILE
="${KEYVAL%%:*}"
74 BRANCH
="${KEYVAL##*:}"
75 echo "Updating ${DEST_FILE}..."
76 git checkout
-q "$BRANCH"
77 git merge
-q origin
/"$BRANCH"
78 for i
in $BUNDLE_LOCALES;
80 mkdir
-p ..
/$LOCALE_DIR/$i/
81 # Some file names are lowercase in Transifex.
82 if [ -f $i/"$DEST_FILE" ]; then
85 SRCFILE
="`echo $DEST_FILE | tr '[:upper:]' '[:lower:]'`"
87 # Use sed to work around a Transifex "double entity" issue.
88 sed -e 's/\&brandShortName;/\&brandShortName;/g' \
89 -e 's/\&vendorShortName;/\&vendorShortName;/g' \
90 $i/"$SRCFILE" > ..
/$LOCALE_DIR/$i/"$DEST_FILE"
95 # Autogenerate brand.ftl based on brand.properties
97 REGEX_ENTITY
='<!ENTITY +([^" ]+) +"(.+)">';
98 for LOCALE
in $BUNDLE_LOCALES;
100 BRAND_PATH
="$LOCALE_DIR/$LOCALE/brand.properties"
101 BRAND_DTD_PATH
="$LOCALE_DIR/$LOCALE/brand.dtd"
102 TOR_BRAND_PATH
="$(dirname "$BRAND_PATH")/branding/brand.ftl"
104 BRAND_SHORTER_NAME
="$(sed -n -e '/^brandShorterName/p' $BRAND_PATH | cut -d= -f2)"
105 BRAND_SHORT_NAME
="$(sed -n -e '/^brandShortName/p' $BRAND_PATH | cut -d= -f2)"
106 BRAND_FULL_NAME
="$(sed -n -e '/^brandFullName/p' $BRAND_PATH | cut -d= -f2)"
107 BRAND_PRODUCT_NAME
="$(sed -n -e '/^brandProductName/p' $BRAND_PATH | cut -d= -f2)"
108 VENDOR_SHORT_NAME
="$(sed -n -e '/^vendorShortName/p' $BRAND_PATH | cut -d= -f2)"
109 TRADEMARK_INFO
='{ " " }'
110 if [[ "$(sed -n -e '/trademarkInfo/p' $BRAND_DTD_PATH)" =~
$REGEX_ENTITY ]]
112 # Replace some HTML entities (now just ") for brand.ftl.
113 TRADEMARK_INFO
="${BASH_REMATCH[2]//"/\'}"
116 echo "# For Tor Browser, we use a new file (different than the brand.ftl file" > $TOR_BRAND_PATH
117 echo "# that is used by Firefox) to avoid picking up the -brand-short-name values" >> $TOR_BRAND_PATH
118 echo "# that Mozilla includes in the Firefox language packs." >> $TOR_BRAND_PATH
119 echo "" >> $TOR_BRAND_PATH
120 echo "-brand-shorter-name = $BRAND_SHORTER_NAME" >> $TOR_BRAND_PATH
121 echo "-brand-short-name = $BRAND_SHORT_NAME" >> $TOR_BRAND_PATH
122 echo "-brand-full-name = $BRAND_FULL_NAME" >> $TOR_BRAND_PATH
123 echo "# This brand name can be used in messages where the product name needs to" >> $TOR_BRAND_PATH
124 echo "# remain unchanged across different versions (Nightly, Beta, etc.)." >> $TOR_BRAND_PATH
125 echo "-brand-product-name = $BRAND_PRODUCT_NAME" >> $TOR_BRAND_PATH
126 echo "-vendor-short-name = $VENDOR_SHORT_NAME" >> $TOR_BRAND_PATH
127 echo "trademarkInfo = $TRADEMARK_INFO" >> $TOR_BRAND_PATH