Im using UB 16.04 LTS Server and today a new version of the locales-package has been released and installed:

Start-Date: 2019-02-21  09:44:05
Commandline: /usr/bin/apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold dist-upgrade
Upgrade: [...], locales:amd64 (2.23-0ubuntu10, 2.23-0ubuntu11), [...]
End-Date: 2019-02-21  09:44:45

I'm additionally using PostgreSQL 11 with databases relying on the character set windows-1252 for historical reasons:

Name  |  Owner   | Encoding |   Collate    |    Ctype     |   Access[...]
[...] | postgres | WIN1252  | de_DE.CP1252 | de_DE.CP1252 |

To make that available, the following command is used:

localedef -f CP1252 -i /usr/share/i18n/locales/de_DE /usr/lib/locale/de_DE.CP1252

Using locale-gen instead gives the following error:

locale-gen de_DE.CP1252
Error: 'de_DE.CP1252' is not a supported language or locale

The problem now is that most likely after the new locales-package has been installed, my manually added one was removed automatically and access to the databases relying on that locale failed:

2019-02-21 09:42:45.109 CET [27039] FATAL:  Datenbank-Locale ist inkompatibel mit Betriebssystem
2019-02-21 09:42:45.109 CET [27039] DETAIL:  Die Datenbank wurde mit LC_COLLATE »de_DE.CP1252« initialisiert, was von setlocale() nicht erkannt wird.

From my understanding, all locales which were recognized and enabled by dpkg-reconfigure locales have been kept and my custom locale is not listed there.

I guess that app provides all locales from the file /usr/share/i18n/SUPPORTED? Do I need to add my custom locale there manually as well? Something like the following doesn't seem to work, the new line is not shown:

de_DE.CP1252 CP1252
de_DE.UTF-8 UTF-8

Actually, my questions consists of two parts: The ultimate goal is to not need to apply localedef more often than necessary and I thought that making my locale recognized by dpkg-reconfigure locales solves that. Sadly, that doesn't seem to be the case.

dpkg-reconfigure locales

The following description is ONLY to make some locale available to dpkg-reconfigure locales, it doesn't solve my problem entirely, which I address in another question. The directory created by localedef /usr/share/i18n/locales/de_DE /usr/lib/locale/de_DE.CP1252 still gets deleted whenever dpkg-reconfigure locales is executed after I did the following described steps.

Another answer brought the file /etc/locale.gen to my attention, which contains the following docs:

# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED, and you can add
# user defined locales to /usr/local/share/i18n/SUPPORTED. If you change
# this file, you need to rerun locale-gen.

So I created /usr/local/share/i18n/SUPPORTED with the following entry and dpkg-reconfigure locales contained the locale I'm interested in:

de_DE.CP1252 CP1252

enter image description here

The file /etc/locale.gen afterwards contained my locale as the last line as well:

# zu_ZA.UTF-8 UTF-8
de_DE.CP1252 CP1252

And with all other lines in that file, disabling my locale using dpkg-reconfigure locales changes the line to become a comment as well:

# zu_ZA.UTF-8 UTF-8
# de_DE.CP1252 CP1252

So, the important thing seems to be making the locale available in the file /usr/local/share/i18n/SUPPORTED instead of the package default at /usr/share/i18n/SUPPORTED.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.