Locale settings: Difference between revisions
No edit summary |
Phase 1 § 5 P1.5.4: style polish — drop leading = title =, convert indented-code to syntaxhighlight, remove first-person example, add sections + See also (via update-page on MediaWiki MCP Server) |
||
| Line 1: | Line 1: | ||
Locale settings control how Linux presents language-dependent things: the language of prompts and error messages, how dates, numbers and currency are formatted, and how "special" characters are handled. | |||
Because Anunna is used by people with many different backgrounds, the cluster sets no default locale — the operating system's own defaults apply, so everything works out of the box. If you want different behaviour, set your preferred locale yourself. Put the settings in your <code>~/.bashrc</code>, and also inside any job scripts, since scripts do not normally read your <code>~/.bashrc</code>. | |||
== Seeing the current settings == | |||
To list the locale categories and the value each currently uses: | |||
<syntaxhighlight lang="bash"> | |||
locale | |||
</syntaxhighlight> | |||
To list the locales available on the system: | |||
<syntaxhighlight lang="bash"> | |||
locale -a | |||
</syntaxhighlight> | |||
To see the detailed keywords of one category (for example monetary formatting): | |||
<syntaxhighlight lang="bash"> | |||
locale -k LC_MONETARY | |||
</syntaxhighlight> | |||
There are two kinds of setting: <code>LANG</code>, the overall default, and the individual <code>LC_*</code> category variables (such as <code>LC_NUMERIC</code> or <code>LC_TIME</code>) that override <code>LANG</code> for one category each. | |||
== Changing your locale == | |||
Set <code>LANG</code> (and optionally <code>LC_ALL</code>, which forces every category at once): | |||
<syntaxhighlight lang="bash"> | |||
export LANG=nl_NL.utf8 | |||
export LC_ALL=nl_NL.utf8 | |||
</syntaxhighlight> | |||
After this you would get error messages in Dutch and the euro sign as the currency symbol. | |||
Note that <code>LC_ALL</code> overrides everything else, so leave it unset if you want to mix categories (see below). | |||
== Mixing categories == | |||
A common wish is to mix locales — for example English-language messages but Danish date and number formatting (which gives unambiguous <code>YYYY-MM-DD</code> dates), with an Irish locale for the decimal separator so numbers use a dot. Because <code>LC_ALL</code> overrides individual categories, first clear it, set a base for all categories, then override the few you want: | |||
<syntaxhighlight lang="bash"> | |||
# LC_ALL overrides per-category settings, so clear it first | |||
unset LC_ALL | |||
# Set every category to English with Danish conventions (e.g. correct dates) | |||
for item in $(locale | grep LC | grep -v LC_ALL | cut -f1 -d'='); do | |||
export ${item}=en_DK.UTF-8 | |||
done | |||
# Override numeric and monetary formatting to get a dot as the decimal separator | |||
export LC_NUMERIC=en_IE.utf8 | |||
export LC_MONETARY=en_IE.utf8 | |||
</syntaxhighlight> | |||
With that in place, <code>locale</code> reports a mixed setup like: | |||
<syntaxhighlight lang="text"> | |||
LANG=en_IE.UTF-8 | |||
LANGUAGE= | |||
LC_CTYPE=en_DK.UTF-8 | |||
LC_NUMERIC=en_IE.UTF-8 | |||
LC_TIME=en_DK.UTF-8 | |||
LC_COLLATE=en_DK.UTF-8 | |||
LC_MONETARY=en_IE.UTF-8 | |||
LC_MESSAGES=en_DK.UTF-8 | |||
LC_PAPER=en_DK.UTF-8 | |||
LC_NAME=nl_NL.utf8 | |||
LC_ADDRESS=nl_NL.utf8 | |||
LC_TELEPHONE=nl_NL.utf8 | |||
LC_MEASUREMENT=en_DK.UTF-8 | |||
LC_IDENTIFICATION=en_DK.UTF-8 | |||
LC_ALL= | |||
</syntaxhighlight> | |||
== See also == | |||
* [[Installing Personal Software]] | |||
Latest revision as of 13:45, 16 June 2026
Locale settings control how Linux presents language-dependent things: the language of prompts and error messages, how dates, numbers and currency are formatted, and how "special" characters are handled.
Because Anunna is used by people with many different backgrounds, the cluster sets no default locale — the operating system's own defaults apply, so everything works out of the box. If you want different behaviour, set your preferred locale yourself. Put the settings in your ~/.bashrc, and also inside any job scripts, since scripts do not normally read your ~/.bashrc.
Seeing the current settings
To list the locale categories and the value each currently uses:
locale
To list the locales available on the system:
locale -a
To see the detailed keywords of one category (for example monetary formatting):
locale -k LC_MONETARY
There are two kinds of setting: LANG, the overall default, and the individual LC_* category variables (such as LC_NUMERIC or LC_TIME) that override LANG for one category each.
Changing your locale
Set LANG (and optionally LC_ALL, which forces every category at once):
export LANG=nl_NL.utf8
export LC_ALL=nl_NL.utf8
After this you would get error messages in Dutch and the euro sign as the currency symbol.
Note that LC_ALL overrides everything else, so leave it unset if you want to mix categories (see below).
Mixing categories
A common wish is to mix locales — for example English-language messages but Danish date and number formatting (which gives unambiguous YYYY-MM-DD dates), with an Irish locale for the decimal separator so numbers use a dot. Because LC_ALL overrides individual categories, first clear it, set a base for all categories, then override the few you want:
# LC_ALL overrides per-category settings, so clear it first
unset LC_ALL
# Set every category to English with Danish conventions (e.g. correct dates)
for item in $(locale | grep LC | grep -v LC_ALL | cut -f1 -d'='); do
export ${item}=en_DK.UTF-8
done
# Override numeric and monetary formatting to get a dot as the decimal separator
export LC_NUMERIC=en_IE.utf8
export LC_MONETARY=en_IE.utf8
With that in place, locale reports a mixed setup like:
LANG=en_IE.UTF-8
LANGUAGE=
LC_CTYPE=en_DK.UTF-8
LC_NUMERIC=en_IE.UTF-8
LC_TIME=en_DK.UTF-8
LC_COLLATE=en_DK.UTF-8
LC_MONETARY=en_IE.UTF-8
LC_MESSAGES=en_DK.UTF-8
LC_PAPER=en_DK.UTF-8
LC_NAME=nl_NL.utf8
LC_ADDRESS=nl_NL.utf8
LC_TELEPHONE=nl_NL.utf8
LC_MEASUREMENT=en_DK.UTF-8
LC_IDENTIFICATION=en_DK.UTF-8
LC_ALL=