Commit 0f3a96c4 authored by Tails developers's avatar Tails developers
Browse files

Fallback to "similar" locale's searchplugins.

E.g. if our locale is pt, which doesn't have localized search plugins,
we'll use one of pt-PT and pt-BR.
parent e57ec5af
...@@ -33,17 +33,18 @@ tor_has_bootstrapped() { ...@@ -33,17 +33,18 @@ tor_has_bootstrapped() {
# Workaround bug #8036 by copying any localized search plugins into # Workaround bug #8036 by copying any localized search plugins into
# the profile. # the profile.
enable_localized_searchplugins() { enable_localized_searchplugins() {
local locale local locale plugin
locale=$(cat "${PROFILE}"/preferences/0000locale.js | \ locale=$(cat "${PROFILE}"/preferences/0000locale.js | \
sed 's@^pref("general\.useragent\.locale", "\([^"]*\)");$@\1@') sed 's@^pref("general\.useragent\.locale", "\([^"]*\)");$@\1@')
if [ "${locale}" = en-US ] || [ -e "${PROFILE}"/searchplugins ]; then if [ "${locale}" = en-US ] || [ -e "${PROFILE}"/searchplugins ]; then
return return
fi fi
PLUGIN_DIR="${TBB_INSTALL}"/distribution/searchplugins/locale/${locale} # Fallback to a similar locale if there is no exact match
if [ -d "${PLUGIN_DIR}" ]; then plugin="$(ls -1 "${TBB_INSTALL}"/distribution/searchplugins/locale/ | grep -m1 "^${locale}\(-[A-Z]\+\)\?$" || true)"
if [ -n "${plugin}" ]; then
mkdir -p "${PROFILE}"/searchplugins mkdir -p "${PROFILE}"/searchplugins
# The plugins do not load if they are symlinks # The plugins do not load if they are symlinks
cp --dereference "${PLUGIN_DIR}"/* "${PROFILE}"/searchplugins cp --dereference "${TBB_INSTALL}"/distribution/searchplugins/locale/"${plugin}"/* "${PROFILE}"/searchplugins
fi fi
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment