{"id":336,"date":"2022-11-20T21:25:00","date_gmt":"2022-11-20T19:25:00","guid":{"rendered":"https:\/\/www.tobanet.de\/s\/?p=336"},"modified":"2022-11-23T11:47:44","modified_gmt":"2022-11-23T09:47:44","slug":"locales-in-debian-and-ubuntu","status":"publish","type":"post","link":"https:\/\/www.tobanet.de\/s\/2022\/11\/locales-in-debian-and-ubuntu\/","title":{"rendered":"Locales in Debian and Ubuntu"},"content":{"rendered":"\n<p>Locales customize your system to languages and country specific settings.<br>On a single user system, you set up your locale at installation time and that&#8217;s it.<br>But if you need to support several different languages (e.g. an international ecommerce shop) you have to tweak your setup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Command line tools, packages and configuration files<\/h2>\n\n\n\n<p>The <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">locale<\/code> command displays information about the <strong>current <\/strong>locale. The man page reveals more information:<\/p>\n\n\n\n<p>When invoked without arguments, <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">locale<\/code> displays the current locale settings for each locale category (see locale(5)), based on the settings of the environment variables that control the locale (see locale(7)).<\/p>\n\n\n\n<p>A locale is composed of several <em>locale categories<\/em>. When a program looks up locale dependent values, it does this according to the following environment variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ locale\nLANG=de_DE.UTF-8\nLANGUAGE=\nLC_CTYPE=\"de_DE.UTF-8\"\nLC_NUMERIC=\"de_DE.UTF-8\"\nLC_TIME=\"de_DE.UTF-8\"\nLC_COLLATE=\"de_DE.UTF-8\"\nLC_MONETARY=\"de_DE.UTF-8\"\nLC_MESSAGES=\"de_DE.UTF-8\"\nLC_PAPER=\"de_DE.UTF-8\"\nLC_NAME=\"de_DE.UTF-8\"\nLC_ADDRESS=\"de_DE.UTF-8\"\nLC_TELEPHONE=\"de_DE.UTF-8\"\nLC_MEASUREMENT=\"de_DE.UTF-8\"\nLC_IDENTIFICATION=\"de_DE.UTF-8\"\nLC_ALL=<\/code><\/pre>\n\n\n\n<p>You can find more information about the variables and locales in general at <a rel=\"noreferrer noopener\" href=\"https:\/\/www.gnu.org\/software\/gettext\/manual\/gettext.html#Locale-Environment-Variables\" target=\"_blank\">https:\/\/www.gnu.org\/software\/gettext\/manual\/gettext.html#Locale-Environment-Variables<\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/help.ubuntu.com\/community\/Locale\" target=\"_blank\">https:\/\/help.ubuntu.com\/community\/Locale<\/a><\/p>\n\n\n\n<p>Display a list of all available locales:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ locale -a\nC\nC.UTF-8\nde_DE.utf8\nPOSIX<\/code><\/pre>\n\n\n\n<p>Locales availabe for generation are configured in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/locales.gen<\/code><br>Just uncomment the locales you want to be available, then run the <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">locale-gen<\/code> command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># This file lists locales that you wish to have built. You can find a list\n# of valid supported locales at \/usr\/share\/i18n\/SUPPORTED, and you can add\n# user defined locales to \/usr\/local\/share\/i18n\/SUPPORTED. If you change\n# this file, you need to rerun locale-gen.\n\n\n# C.UTF-8 UTF-8\n# aa_DJ ISO-8859-1\n# aa_DJ.UTF-8 UTF-8\n# aa_ER UTF-8\n\n...\n\n# de_CH.UTF-8 UTF-8\n# de_DE ISO-8859-1\nde_DE.UTF-8 UTF-8\n# de_DE@euro ISO-8859-15\n# de_IT ISO-8859-1\n# de_IT.UTF-8 UTF-8\n# de_LI.UTF-8 UTF-8\n\n...<\/code><\/pre>\n\n\n\n<p>As an alternative, you could achieve the same result with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo locale-gen fr_FR.UTF-8\nGenerating locales...\n  fr_FR.UTF-8... done\nGeneration complete.<\/code><\/pre>\n\n\n\n<p>This will update the config file und generate the specified locale (fr_FR.UTF-8) in one step.<\/p>\n\n\n\n<p>If you have a bunch of locales to generate the following shell snippet will help:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ L=\"de_DE\nde_DE.UTF-8\nde_DE@euro\nen_GB\nen_GB.ISO-8859-15\nen_GB.UTF-8\nen_US.UTF-8\nes_ES\nes_ES.UTF-8\nes_ES@euro\nfr_FR\nfr_FR.UTF-8\nfr_FR@euro\nit_IT\nit_IT.UTF-8\nit_IT@euro\nnl_NL\nnl_NL.UTF-8\nnl_NL@euro\"\n\n$ for i in $L&#91;*]; do\n$  sudo sed -i s\"\/^# ${i}\/${i}\/g\" locale.gen\n$ done\n \n$ sudo locale-gen\nGenerating locales (this might take a while)...\n  de_DE.ISO-8859-1... done\n  de_DE.UTF-8... done\n  de_DE.ISO-8859-15@euro... done\n  en_GB.ISO-8859-1... done\n  en_GB.ISO-8859-15... done\n  en_GB.UTF-8... done\n  en_US.UTF-8... done\n  es_ES.ISO-8859-1... done\n  es_ES.UTF-8...^A done\n  es_ES.ISO-8859-15@euro... done\n  fr_FR.ISO-8859-1... done\n  fr_FR.UTF-8... done\n  fr_FR.ISO-8859-15@euro... done\n  it_IT.ISO-8859-1... done\n  it_IT.UTF-8... done\n  it_IT.ISO-8859-15@euro... done\n  nl_NL.ISO-8859-1... done\n  nl_NL.UTF-8... done\n  nl_NL.ISO-8859-15@euro... done\nGeneration complete.<\/code><\/pre>\n\n\n\n<p>The <strong>default <\/strong>locale is defined in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/default\/locale<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LANG=de_DE.UTF-8<\/code><\/pre>\n\n\n\n<p>To change the default, you can edit the file or use <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">update-locale<\/code> like so<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo update-locale LANG=de_DE.UTF-8<\/code><\/pre>\n\n\n\n<p>The advantage of using <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">update-locale<\/code> ist that some basic checks are performed to ensure that requested settings are valid.<\/p>\n\n\n\n<p><strong>Conclusion so far:<\/strong> with the tools described above you can cherry pick how locales are setup.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Language packs<\/h3>\n\n\n\n<p><strong>Important: language-packs only apply to Ubuntu and not Debian<\/strong><\/p>\n\n\n\n<p>On Ubuntu you can also install <strong>language-packs<\/strong>.<br>There are a lot of them, seperated into base and updates packages, for example:<\/p>\n\n\n\n<p><strong>language-pack-en<\/strong>: translation updates for language English<br>Translation data updates for all supported packages for: English<br><strong>language-pack-en-base<\/strong> provides the bulk of translation data and is updated<br>only seldom. This package provides frequent translation updates.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo aptitude search \"^language-pack-*\"\np   language-pack-af               - translation updates for language Afrikaans\np   language-pack-af-base          - translations for language Afrikaans\np   language-pack-am               - translation updates for language Amharic\np   language-pack-am-base          - translations for language Amharic\np   language-pack-an               - translation updates for language Aragonese\np   language-pack-an-base          - translations for language Aragonese\np   language-pack-ar               - translation updates for language Arabic\np   language-pack-ar-base          - translations for language Arabic\np   language-pack-as               - translation updates for language Assamese\np   language-pack-as-base          - translations for language Assamese\np   language-pack-ast              - translation updates for language Asturian\np   language-pack-ast-base         - translations for language Asturian\np   language-pack-az               - translation updates for language Azerbaijan\np   language-pack-az-base          - translations for language Azerbaijani\np   language-pack-be               - translation updates for language Belarusian\np   language-pack-be-base          - translations for language Belarusian\np   language-pack-bg               - translation updates for language Bulgarian\np   language-pack-bg-base          - translations for language Bulgarian\np   language-pack-bn               - translation updates for language Bengali\np   language-pack-bn-base          - translations for language Bengali\np   language-pack-br               - translation updates for language Breton\np   language-pack-br-base          - translations for language Breton\n\n...<\/code><\/pre>\n\n\n\n<p>If you install a language-pack, additional configuration is installed in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/var\/lib\/locales\/supported.d<\/code><br>For English this will look like this:<\/p>\n\n\n\n<p><code>\/var\/lib\/locales\/supported.d\/en<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>en_HK.UTF-8 UTF-8\nen_DK.UTF-8 UTF-8\nen_IN UTF-8\nen_IL UTF-8\nen_ZM UTF-8\nen_ZW.UTF-8 UTF-8\nen_NZ.UTF-8 UTF-8\nen_PH.UTF-8 UTF-8\nen_NG UTF-8\nen_US.UTF-8 UTF-8\nen_GB.UTF-8 UTF-8\nen_AU.UTF-8 UTF-8\nen_SG.UTF-8 UTF-8\nen_BW.UTF-8 UTF-8\nen_AG UTF-8\nen_ZA.UTF-8 UTF-8\nen_CA.UTF-8 UTF-8\nen_IE.UTF-8 UTF-8<\/code><\/pre>\n\n\n\n<p>Independently from the settings in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/locale.gen<\/code> all the locales in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/var\/lib\/locales\/supported.d\/en<\/code> are beeing generated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Locales customize your system to languages and country specific settings.On a single user system, you set up your locale at installation time and that&#8217;s it.But if you need to support several different languages (e.g. an international ecommerce shop) you have to tweak your setup. Command line tools, packages and configuration files The locale command displays information about the current locale. The man page reveals more information: When invoked without arguments, locale displays the current locale settings for each locale category&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.tobanet.de\/s\/2022\/11\/locales-in-debian-and-ubuntu\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[29,30],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-linux","tag-debian","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":3,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":352,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/336\/revisions\/352"}],"wp:attachment":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}