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)
|
list)
|
||||||
localectl list-locales
|
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
|
then
|
||||||
echo "Invalid locale entered."
|
echo "Invalid locale entered."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
LANG="$_acp_entered_locale"
|
if [ -z "$_acp_entered_locale" ]
|
||||||
LC_COLLATE="$LANG" # Alphabetic sorting.
|
then
|
||||||
LC_CTYPE="$LANG" # Interpretation of byte sequences.
|
LANG=C.utf8
|
||||||
LC_IDENTIFICATION="$LANG" # Locale metadata (GNU).
|
else
|
||||||
LC_MEASUREMENT="$LANG" # Units of measure -- metric/imperial (GNU).
|
LANG="$_acp_entered_locale"
|
||||||
LC_MESSAGES="$LANG" # Language that messages are displayed in.
|
fi
|
||||||
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"
|
|
||||||
_acp_locale_selected=1
|
_acp_locale_selected=1
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
done
|
||||||
|
unset _acp_locale_selected
|
||||||
|
unset _acp_entered_locale
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -r "$HOME/.config/locale.conf" ]
|
if [ -r "$HOME/.config/locale.conf" ]
|
||||||
|
|
Loading…
Reference in a new issue