factorized code / thiner implementation
This commit is contained in:
@@ -34,39 +34,67 @@
|
||||
# * OF SUCH DAMAGE.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
locale_check() {
|
||||
locale -a | grep -qx "$1" || {
|
||||
disp W "Locale '$1' is not installed on this system."
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Change locale to the given one in parameter
|
||||
# ------------------------------------------------------------------------------
|
||||
setlocale()
|
||||
{
|
||||
local loc=$1
|
||||
[[ -z $loc ]] && disp E "No locale specified." && return 1
|
||||
|
||||
locale_check "$loc" || return 1
|
||||
|
||||
export LANG=$loc
|
||||
export LC_MESSAGES=$loc
|
||||
export LC_TIME=$loc
|
||||
export LC_NUMERIC=$loc
|
||||
export LC_MONETARY=$loc
|
||||
export LC_COLLATE=$loc
|
||||
export LC_CTYPE=$loc
|
||||
|
||||
disp I "Locale set to $loc."
|
||||
}
|
||||
export -f setlocale
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Special case : change locale to C standard
|
||||
# ------------------------------------------------------------------------------
|
||||
setc()
|
||||
{
|
||||
# Locale definitions
|
||||
export LC_ALL=C
|
||||
disp I "Locale changed to standard C (POSIX)."
|
||||
}
|
||||
export -f setc
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Change locale to French
|
||||
# ------------------------------------------------------------------------------
|
||||
setfr()
|
||||
{
|
||||
# Set fr locale definitions
|
||||
export LANG=fr_FR.UTF-8
|
||||
export LC_MESSAGES=fr_FR.UTF-8
|
||||
export LC_ALL=fr_FR.UTF-8
|
||||
setlocal "fr_FR.UTF-8"
|
||||
}
|
||||
export -f setfr
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Change locale to C standard
|
||||
# ------------------------------------------------------------------------------
|
||||
setc()
|
||||
{
|
||||
# Locale definitions
|
||||
export LANG=C
|
||||
export LC_MESSAGES=C
|
||||
export LC_ALL=C
|
||||
}
|
||||
export -f setc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Change locale to US (needed by Steam)
|
||||
# ------------------------------------------------------------------------------
|
||||
setus()
|
||||
{
|
||||
# Locale definitions
|
||||
export LANG=en_US.UTF-8
|
||||
export LC_MESSAGES=en_US.UTF-8
|
||||
export LC_ALL=en_US.UTF-8
|
||||
setlocal "en_US.UTF-8"
|
||||
}
|
||||
export -f setus
|
||||
|
||||
|
||||
Reference in New Issue
Block a user