summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-patches/browser-localization.patch
blob: aba1ab84807d1ae561ac12d251d369c9408e4056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--- chroot.orig/etc/gdm3/PostLogin/Default	2014-10-03 02:16:53.170723099 +0200
+++ chroot/etc/gdm3/PostLogin/Default	2014-10-03 02:14:07.235916994 +0200
@@ -130,6 +130,32 @@
 XKBOPTIONS="$TAILS_XKBOPTIONS"
 EOF
 
+# Chose which browser language pack to use
+LONG_LOCALE="$(echo ${TAILS_LOCALE_NAME} | sed -e 's/\..*$//' -e 's/_/-/')"
+SHORT_LOCALE="$(echo ${LONG_LOCALE} | cut -d"-" -f1)"
+LANGPACK_DIR="/usr/local/lib/tor-browser/extensions"
+if [ -e "${LANGPACK_DIR}/langpack-${LONG_LOCALE}@firefox.mozilla.org.xpi" ]; then
+    BROWSER_LOCALE="${LONG_LOCALE}"
+elif [ -e "${LANGPACK_DIR}/langpack-${SHORT_LOCALE}@firefox.mozilla.org.xpi" ]; then
+    BROWSER_LOCALE="${SHORT_LOCALE}"
+else
+    BROWSER_LOCALE="en-US"
+fi
+TOR_LAUNCHER_LOCALES_DIR=/usr/share/tor-launcher-standalone/chrome/locale
+if [ -e "${TOR_LAUNCHER_LOCALES_DIR}/${LONG_LOCALE}" ]; then
+    TOR_LAUNCHER_LOCALE="${LONG_LOCALE}"
+elif [ -e "${TOR_LAUNCHER_LOCALES_DIR}/${SHORT_LOCALE}" ]; then
+    TOR_LAUNCHER_LOCALE="${SHORT_LOCALE}"
+else
+    TOR_LAUNCHER_LOCALE="en-US"
+fi
+echo "pref(\"general.useragent.locale\", \"${BROWSER_LOCALE}\");" > \
+     /var/lib/tails-user-session/browser-locale.js
+echo "pref(\"general.useragent.locale\", \"${TOR_LAUNCHER_LOCALE}\");" > \
+     /var/lib/tails-user-session/tor-launcher-locale.js
+chmod 664 /var/lib/tails-user-session/browser-locale.js \
+          /var/lib/tails-user-session/tor-launcher-locale.js
+
 ### Persistence
 
 # Copy persistence configuration to a root-writable, world-readable place,