How to set locale in Linux
Too often we can see that locale is not properly set in the Linux server. After failed attempts to change environment variables and (re)configure locale using dpkg-reconfigure, not much is left, but to update environment files manually. Why is correct locate important? Today there are simply too many if not all programs that are dependent on the correct locale. Suddenly, after trying to run one of them, you get an error that does not give too much sense. Then you start digging and realize that everything points to the general system, and finally to locale. So let\’s take a look at how to configure locale so that your system works the way you expect it to.\nWe can start with “after the book” example of setting locale using the following:\n
# export LANGUAGE=en_GB.UTF-8 # export LANG=en_GB.UTF-8 # export LC_ALL=en_GB.UTF-8 locale-gen en_GB.UTF-8 ndpkg-reconfigure locales\nreboot
After the reboot, check your locale issuing the following command:
locale
If you see the 3 aforementioned variables empty and everything else set to POSIX, then you need to manually update your locale configuration. You will need to edit 2 files /etc/default/locale and /etc/environment. Both files should contain the same 3 lines, as follows:
LANGUAGE="en_GB.UTF-8" LANG="en_GB.UTF-8" LC_ALL="en_GB.UTF-8"
After saving files, reboot your server and run the locale command again. Now you should see all of your locale variables set to en_GB.UTF-8.’,’How to set locale in Ubuntu Linux