Locales: Difference between revisions

Jooooscha (talk | contribs)
Add a note about the syntactic differences in setting the supported locales and the extra locale settings
Partially taken from nixos.wiki/wiki/Locales to give a full picture. Adjusted/shortened some part to fit and fixed some spelling errors
Line 1: Line 1:
== Notes when setting supportedLocales and extraLocaleSettings ==
Beaware when setting up your locale variables. The setting <code>i18n.supportedLocales</code> requires a different format to <code>i18n.extraLocaleSettings</code>.


The setting <code>i18n.supportedLocales</code> requries the requires the language string '''with''' the added <code>/UTF-8</code>


<syntaxhighlight lang="bash">
NixOS allows to set the default locale as well as individual locales in the configuration file:<syntaxhighlight lang="bash">
"en_US.UTF-8/UTF-8"
configuration.nix
"nl_NL.UTF-8/UTF-8"
{...}
</syntaxhighlight>


The setting <code>i18n.extraLocaleSettings</code>, however, requires the language string '''without''' any suffix.
# Mandatory
i18n.defaultLocale = "en_US.UTF-8";


<syntaxhighlight lang="bash">
# Optionally (BEWARE: requires a different format with the added /UTF-8)
LC_MESSAGES = "en_US.UTF-8"
i18n.i18n.supportedLocales = ["en_US.UTF-8/UTF-8" "es_VE.UTF-8/UTF-8"];
LC_TIME = "de_DE.UTF-8"
 
</syntaxhighlight>Otherwise, your locale settings will likely not work.
# Optionally
i18n.extraLocaleSettings = {
    LC_ALL = "en_US.UTF-8";
    LC_CTYPE = "en_US.UTF8";
    LC_ADDRESS = "es_VE.UTF-8";
    LC_IDENTIFICATION = "es_VE.UTF-8";
    LC_MEASUREMENT = "es_VE.UTF-8";
    LC_MESSAGES = "en_US.UTF-8";
    LC_MONETARY = "es_VE.UTF-8";
    LC_NAME = "es_VE.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "es_VE.UTF-8";
    LC_TELEPHONE = "es_VE.UTF-8";
    LC_TIME = "es_VE.UTF-8";
    LC_COLLATE = "es_VE.UTF-8";
  };
</syntaxhighlight>'''defaultLocale''' will set the locale systemwide to the desired value. In addition, with '''supportedLocales''', the system will also support Venezuelan Spanish. And in the '''extraLocaleSettings''', it is possible to set the LC locales individually. This does allow fine-grained adjustments of the used locales. In the above example a mix of American English and Venezuelan Spanish is used. It is also possible to find these settings at [https://search.nixos.org/options NixOS options]. Just search for i18 locale.
 
'''BEWARE:''' The setting <code>i18n.supportedLocales</code> requires a different format to <code>i18n.extraLocaleSettings</code>  with the added <code>/UTF-8</code>. Otherwise, your locale settings will likely not work.


== Troubleshooting when using nix on non-NixOS linux distributions ==
== Troubleshooting when using nix on non-NixOS linux distributions ==