Last active
May 29, 2018 02:57
-
-
Save tonejito/f4bcde9e6bfb7e8c9df2612d588d41ea to your computer and use it in GitHub Desktop.
fix-locale - Configure system messages in en_US and use other locale for everything else
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# fix-locale - Configure system messages in en_US and use other locale for everything else | |
# Andres Hernandez - tonejito | |
# https://gist.github.com/tonejito/f4bcde9e6bfb7e8c9df2612d588d41ea | |
# https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_locale | |
# https://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_customized_display_of_time_and_date | |
# https://help.ubuntu.com/community/Locale | |
# https://stackoverflow.com/a/16553351 | |
# http://mywiki.wooledge.org/BashFAQ/006#Indirection | |
# http://tldp.org/LDP/abs/html/ivr.html | |
# Provides default value for LC_* variables that have not been explicitly set. | |
LANG=es_MX.UTF-8 | |
LANGUAGE=es_MX:es | |
# Overrides individual LC_* settings: if LC_ALL is set, none of the below have any effect. | |
LC_ALL= | |
# What language should be used for system messages. | |
LC_MESSAGES=en_US.UTF-8 | |
# Determines how responses (such as Yes and No) appear in the local language | |
LC_RESPONSE=en_US.UTF-8 | |
# How characters are classified as letters, numbers etc. | |
# This determines things like how characters are converted between upper and lower case. | |
LC_CTYPE=es_MX.UTF-8 | |
# How strings (file names...) are alphabetically sorted. | |
# Using the "C" or "POSIX" locale here results in a strcmp()-like sort order, | |
# which may be preferable to language-specific locales. | |
LC_COLLATE=es_MX.UTF-8 | |
# How you format your numbers. | |
# For example, in many countries a period (.) is used as a decimal separator, | |
# while others use a comma (,). | |
LC_NUMERIC=es_MX.UTF-8 | |
# How your time and date are formatted. | |
# Use for example "en_DK.UTF-8" to get a 24-hour-clock in some programs. | |
LC_TIME=es_MX.UTF-8 | |
# What currency you use, its name, and its symbol. | |
LC_MONETARY=es_MX.UTF-8 | |
# Paper sizes: 11 x 17 inches, A4, etc. | |
LC_PAPER=es_MX.UTF-8 | |
# How names are represented (surname first or last, etc.). | |
LC_NAME=es_MX.UTF-8 | |
# How addresses are formatted (country first or last, where zip code goes etc.). | |
LC_ADDRESS=es_MX.UTF-8 | |
# What your telephone numbers look like. | |
LC_TELEPHONE=es_MX.UTF-8 | |
# What units of measurement are used (feet, meters, pounds, kilos etc.). | |
LC_MEASUREMENT=es_MX.UTF-8 | |
# Metadata about the locale information. | |
LC_IDENTIFICATION=es_MX.UTF-8 | |
ARGS="" | |
# Build ARGS list from variables | |
for VAR in \ | |
LANG LANGUAGE LC_ALL \ | |
LC_MESSAGES LC_RESPONSE \ | |
LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME LC_MONETARY LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION | |
do | |
# From update-locale(8) | |
# When variables have no value assigned, they are removed from the locale file. | |
if [ -z "${!VAR}" ] | |
then | |
# Pass empty VAR to ARGS | |
ARGS="${ARGS} ${VAR} " | |
else | |
# Pass VAR=value to ARGS | |
ARGS="${ARGS} ${VAR}=${!VAR} " | |
fi | |
done | |
# Configure system to match configuration | |
echo "${PS2} dpkg-reconfigure -p low locales" | |
dpkg-reconfigure -p low locales | |
echo $? | |
echo "${PS2} egrep -v '^\s*(#|$)' /etc/locale.gen" | |
egrep -v '^\s*(#|$)' /etc/locale.gen | |
echo $? | |
echo "${PS2} update-locale ${ARGS}" | |
update-locale ${ARGS} | |
echo $? | |
echo "${PS2} cat /etc/default/locale" | |
cat /etc/default/locale | |
echo $? | |
echo "${PS2} locale" | |
locale | |
echo $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment