I am trying to create a new system locale. I have studied the directions at Unix Stackexchange and at Ask Ubuntu but my attempts to get my environment variable into /etc/locale.gen have been unsuccessful.

I have created my environment variable according to Sourceware and copied it into /usr/share/i18n/locales. (All I'm really doing is using en_US and changing the LC_TIME variable to use en_DK, so I copied the LC_TIME portion of en_DK into en_US and I am trying to make this into a new variable so that is lasts through updates. Changing the LC_TIME portion within the en_US file is not working because updates often reset it back to its original state).

Let's call my new variable en_US@XX. After I copied my variable, running ls /usr/share/i18n/locales shows my new variable in the listing.

Now I run sudo localedef -i en_US@XX --quiet -f UTF-8 en_US@XX.UTF-8 and nothing is reported by bash leading me to believe everything was successfully done. But when I cat /etc/locale.gen | less my variable is not present. I have also tried command sudo localedef -i en_US@XX -c -f UTF-8 en_US@XX.UTF-8 but this doesn't work either.

If I can just get my variable into /etc/locale.gen, then I can run sudo locale-gen and I should be good.

So how do I get my variable to appear in /etc/locale.gen? Am I misunderstanding what localedef is supposed to be doing? Don't I need to get my variable into /etc/locale.gen to be able to generate it for system use?


What you seem to have missed is adding you custom locale to


with the line

en_US@XX UTF-8

Then a simple sudo locale-gen should do what you want.

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.