# ------------------------------------------------------------------------------ # Configure locale # Copyright (c) 2019-2021 Geoffray Levasseur # ------------------------------------------------------------------------------ # This file is distributed under 3-clause BSD license. # The complete license agreement can be obtained at: # https://opensource.org/licenses/BSD-3-Clause # ------------------------------------------------------------------------------ # Variable: # * LOCALESET: List of locale that will be supported by system # * SYSLOCALE: Default system wide locale # # Both case will be formated in that way (with exemple for French: # fr_FR.UTF-8 # ^ ^ ^ # | | | # ISO-631-1 language code | | # ISO 3166-2 country subdivision | # Character table (ISO or UTF) # ------------------------------------------------------------------------------ export VER_conf_locale="0.0.3" conf_locale() { backupdist /etc/locale.gen for loc in $LOCALESET; do prnt I "Activation de la locale ${loc}..." sed -i "/^# $loc /s/^# //" /etc/locale.gen done prnt I "Régénération du cache de locale..." locale-gen prnt I "Définition de la langue du systême..."* [[ ! $SYSLOCALE ]] && export SYSLOCALE=C local fname=/etc/default/locale backupdist $fname echo "# Generated by init on $(stdtime)" > $fname echo "LANG=$SYSLOCALE" >> $fname for cfg in ADDRESS IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER \ TELEPHONE TIME; do echo "LC_$cfg=$SYSLOCALE" done } precheck_conf_locale() { if [[ -z $LOCALESET ]]; then prnt W "Aucune locale définie !" else prnt m "Les locales disponibles seront : $LOCALESET" fi if [[ -z $SYSLOCALE ]]; then prnt W "Pas de locale systême définie, C sera utilié." export SYSLOCALE="C" fi prnt m "La locale par défaut sera : $SYSLOCALE" } export -f conf_locale export -f precheck_conf_locale