summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh')
-rw-r--r--config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh b/config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh
new file mode 100644
index 0000000..df7dd7c
--- /dev/null
+++ b/config/chroot_local-includes/usr/local/lib/tails-shell-library/localization.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Extracts the language part of a given locale, e.g. "en_US.UTF-8"
+# yields "en". Often $LANG will be passed as the argument.
+language_code_from_locale () {
+ echo "${1}" | sed "s,\(_\|\.\).*$,,"
+}
+
+# Prints the path to the localized (according to the environment's
+# LANG) version of `page` in the local copy of Tails' website. `page`
+# should specify only the name of the page, not the language code (of
+# course!) or the ".html" extension. If a localized page doesn't exist
+# the default is the English version.
+localized_tails_doc_page () {
+ local page="${1}"
+ local lang_code="$(language_code_from_locale "${LANG}")"
+ local try_page
+ for locale in "${lang_code}" "en"; do
+ try_page="${page}.${locale}.html"
+ if [ -r "${try_page}" ]; then
+ echo "${try_page}"
+ return 0
+ fi
+ done
+ return 1
+}