Fix language management

This commit is contained in:
Josué Tille 2024-04-26 23:35:01 +02:00
parent f7c3546bc8
commit b0580c33e6
No known key found for this signature in database
GPG key ID: 5F259226AD51F2F5
2 changed files with 10 additions and 21 deletions

View file

@ -310,11 +310,7 @@ TIME_ZONE = "{{ time_zone }}"
LANGUAGE_CODE = '{{ language }}'
# Custom language code choice.
LANGUAGES = (
{%- for lang in lang_list.splitlines() -%}
('{{ lang.split(',')[0]}}', '{{ lang.split(',')[1] }}'),
{%- endfor %}
)
# LANGUAGES = ( )
# Set this to your website/company's name. This is contained in email notifications and welcome message when user login for the first time.
SITE_NAME = 'Seafile'

View file

@ -2,29 +2,22 @@
# SET ALL CONSTANTS
#=================================================
time_zone=$(cat /etc/timezone)
language=$(echo $LANG | cut -d_ -f1)
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
readonly time_zone="$(cat /etc/timezone)"
readonly python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
# Create special path with / at the end
if [[ $path == '/' ]]
then
path2="$path"
readonly path2="$path"
else
path2="$path/"
readonly path2="$path/"
fi
lang_map() {
while read -r item; do
if [ "$item" == en ]; then
lang_name=english
if [ "${LANG:0:2}" == C. ]; then
readonly language=en
else
lang_name="$((grep -E "^[a-z]+[[:space:]]+${item}_" /usr/share/locale/locale.alias || echo "$item") | head -n1 | cut -f1)"
readonly language="${LANG:0:2}"
fi
echo "$item,$lang_name"
done
}
lang_list=$(grep -E '^[a-z]' /etc/locale.gen | cut -d_ -f1 | uniq | lang_map)
#=================================================
# DEFINE ALL COMMON FONCTIONS