Properly handle empty locale selection
This commit is contained in:
parent
f4a89b7a25
commit
5a56df3d36
1 changed files with 26 additions and 20 deletions
|
@ -51,35 +51,41 @@ _acp_set_locale () {
|
|||
list)
|
||||
localectl list-locales
|
||||
;;
|
||||
"")
|
||||
LANG=C
|
||||
_acp_locale_selected=1
|
||||
;;
|
||||
*)
|
||||
if [ $(localectl list-locales | grep "$_acp_entered_locale" | wc -l) -eq 0 ]
|
||||
if [ $(localectl list-locales | grep "${_acp_entered_locale}" | wc -l) -eq 0 ]
|
||||
then
|
||||
echo "Invalid locale entered."
|
||||
continue
|
||||
fi
|
||||
LANG="$_acp_entered_locale"
|
||||
LC_COLLATE="$LANG" # Alphabetic sorting.
|
||||
LC_CTYPE="$LANG" # Interpretation of byte sequences.
|
||||
LC_IDENTIFICATION="$LANG" # Locale metadata (GNU).
|
||||
LC_MEASUREMENT="$LANG" # Units of measure -- metric/imperial (GNU).
|
||||
LC_MESSAGES="$LANG" # Language that messages are displayed in.
|
||||
LC_NAME="$LANG" # Salutations and titles (GNU).
|
||||
LC_NUMERIC="$LANG" # Formatting for non-monetary numbers.
|
||||
LC_TIME="$LANG" # Time format.
|
||||
LC_ADDRESS="$LANG" # Postal address (GNU).
|
||||
LC_MONETARY="$LANG" # Currency display.
|
||||
LC_PAPER="$LANG" # Standard paper size -- A4 or Letter (GNU).
|
||||
LC_TELEPHONE="$LANG" # Formats for telephone services (GNU).
|
||||
rm -f "$HOME/.config/locale.conf"
|
||||
locale > "$HOME/.config/locale.conf"
|
||||
if [ -z "$_acp_entered_locale" ]
|
||||
then
|
||||
LANG=C.utf8
|
||||
else
|
||||
LANG="$_acp_entered_locale"
|
||||
fi
|
||||
_acp_locale_selected=1
|
||||
;;
|
||||
esac
|
||||
LC_COLLATE="$LANG" # Alphabetic sorting.
|
||||
LC_CTYPE="$LANG" # Interpretation of byte sequences.
|
||||
LC_IDENTIFICATION="$LANG" # Locale metadata (GNU).
|
||||
LC_MEASUREMENT="$LANG" # Units of measure -- metric/imperial (GNU).
|
||||
LC_MESSAGES="$LANG" # Language that messages are displayed in.
|
||||
LC_NAME="$LANG" # Salutations and titles (GNU).
|
||||
LC_NUMERIC="$LANG" # Formatting for non-monetary numbers.
|
||||
LC_TIME="$LANG" # Time format.
|
||||
LC_ADDRESS="$LANG" # Postal address (GNU).
|
||||
LC_MONETARY="$LANG" # Currency display.
|
||||
LC_PAPER="$LANG" # Standard paper size -- A4 or Letter (GNU).
|
||||
LC_TELEPHONE="$LANG" # Formats for telephone services (GNU).
|
||||
if [ ! -z "$_acp_entered_locale" ]
|
||||
then
|
||||
rm -f "$HOME/.config/locale.conf"
|
||||
locale > "$HOME/.config/locale.conf"
|
||||
fi
|
||||
done
|
||||
unset _acp_locale_selected
|
||||
unset _acp_entered_locale
|
||||
}
|
||||
|
||||
if [ -r "$HOME/.config/locale.conf" ]
|
||||
|
|
Loading…
Reference in a new issue