37

A remote installed application has some encoding problems and on my local machine it is running fine.

What is the best way to "copy" my locales to the remote machine?

The locales on my personal machine are configured like this:

$ locale
LANG=de_DE.UTF-8
LANGUAGE=de_DE:en
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
Anwar
  • 75,875
  • 31
  • 191
  • 309
d0x
  • 496
  • 1
  • 4
  • 9

3 Answers3

35

You can set locale manually using update-locale:

sudo update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX

Read the man page for more information.

Alternatively, you can manually change your system's locale entries by modifying the file /etc/default/locale.

For example, on a German system, to prevent system messages from being translated, you may use:

LANG=de_DE.UTF-8
LC_MESSAGES=POSIX

Note: changes take effect only after a fresh login.

Source: https://help.ubuntu.com/community/Locale

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
green
  • 14,240
  • 8
  • 41
  • 64
13

The easier way

  1. Export all locales into a file

    locale > import

  2. Open file and add export at the start of each line

  3. Make it executable with the command chmod ugo+rx import

  4. Copy to desired profile and execute ./import

6

There are some recommendations when configuring locales in remote machines

  1. In Debian machines (remote machine), run the command (as root):

    sudo dpkg-reconfigure locales
    

    On the first screen, select the desired locales. After that, you will be prompted to choose which is the default locale. Select "none" (reference: https://wiki.debian.org/Locale#Standard).

  2. Configure your ssh service (/etc/ssh/sshd_config) to accept environment variables from the client: uncomment the line:

    AcceptEnv LANG LC_*
    

Restart your ssh server, logoff and log back in and run the locale command. It must match your local machine's locale.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Girol
  • 171
  • 2
  • 5
  • 2
    You said "On the first screen, select the desired locales", but I have tested on Ubuntu V14.04.2LTS and all the process is done automatically (`Generating locales...` ... and later `Generation complete.`) I get no selection screen. – Sopalajo de Arrierez Mar 14 '15 at 00:02
  • @SopalajodeArrierez did you solve that? – Girol Feb 13 '18 at 16:32
  • Well, as for today, I am using v16.04 and, indeed, the "first screen" exists and I can select the desired locales. Maybe it was just a problem with v14. – Sopalajo de Arrierez Feb 14 '18 at 02:26
  • Nice! Sorry about my **huge** delay. I didn't know how to use this tool that time and forgot about my account since then. Best regards. – Girol Feb 14 '18 at 03:06