Guide to Configuring Multi-Language Locale Support on Ubuntu Linux

September 30, 2025
Published in System Administration

Abstract

Configuring locale settings correctly is essential for a smooth multilingual experience on Linux systems. Whether you're a developer working with international applications or a user who needs multiple language support, understanding how to properly set up locales can save you from cryptic warnings and unexpected behavior. This guide will walk you through the complete process of configuring multi-language locale support on Ubuntu Linux.

Keywords: Linux, Ubuntu, Locale, i18n, Configuration

Understanding Linux Locales

Before diving into the configuration, it's important to understand what locales are and why they matter. A locale is a set of parameters that defines the user's language, country, and character encoding preferences. It affects:

  • Language: The language used by applications for messages and interface text
  • Date and time formats: How dates and times are displayed
  • Number formatting: Decimal separators, thousands separators, etc.
  • Currency: Currency symbols and formatting
  • Character encoding: How text is stored and displayed (typically UTF-8)

You might encounter locale warnings when:

  • Installing or updating packages
  • Running applications that require specific locale support
  • SSH-ing into remote servers
  • Using applications with multilingual features

These warnings typically look like:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings...

Checking Your Current Locale Configuration

Before making any changes, let's check the current locale configuration:

locale

This command displays all locale-related environment variables. You might see output like:

LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en_GB
LC_ALL=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
...

To see which locales are currently available on your system:

locale -a

Step-by-Step Configuration Guide

Step 1: Generate and Install Required Locales

First, we need to generate the locale files for the languages we want to support. In this example, we'll configure support for Chinese (China), British English, and German:

sudo locale-gen zh_CN.UTF-8 en_GB.UTF-8 de_DE.UTF-8

This command generates the necessary locale data files. You should see output indicating that each locale is being generated.

Next, reconfigure the locale packages to ensure everything is properly registered:

sudo dpkg-reconfigure locales

This will open an interactive dialog where you can:

  • Use Space to select/deselect locales
  • Select: zh_CN.UTF-8, en_GB.UTF-8, and de_DE.UTF-8
  • Press Tab to move to "OK" and press Enter
  • Choose your default locale (typically zh_CN.UTF-8 if Chinese is your primary language)

Step 2: Configure System-Wide Locale Settings

Edit the system-wide locale configuration file:

sudo nano /etc/default/locale

Replace its contents with:

LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en_GB:de_DE
LC_ALL=zh_CN.UTF-8

Understanding these variables:

  • LANG: Sets the default locale for all categories
  • LANGUAGE: Defines the fallback language priority list (if Chinese translation is unavailable, try British English, then German)
  • LC_ALL: Overrides all other locale settings (use with caution)

Step 3: Update System Environment

Apply the changes system-wide using the update-locale command:

sudo update-locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:en_GB:de_DE LC_ALL=zh_CN.UTF-8

This ensures that the locale settings are properly registered in the system configuration.

Step 4: Apply Changes

To make the changes effective, you have two options:

Option A: Source the configuration file (temporary, current session only)

source /etc/default/locale

Logging out and back in ensures all processes start with the new locale settings.

Step 5: Verify the Configuration

Check that your new locale configuration is active:

locale

You should now see output that includes support for Chinese, British English, and German locales:

LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en_GB:de_DE
LC_ALL=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
...

Verify that all required locales are available:

locale -a | grep -E "zh_CN|en_GB|de_DE"

You should see:

de_DE.utf8
en_GB.utf8
zh_CN.utf8

Understanding the LANGUAGE Variable

The LANGUAGE variable deserves special attention. It defines a priority list for language selection:

LANGUAGE=zh_CN:en_GB:de_DE

This means:

  1. Applications will first try to display content in Chinese (Simplified, China)
  2. If Chinese translations are not available, they'll fall back to British English
  3. If British English is unavailable, they'll try German
  4. If all else fails, they'll use the default C/POSIX locale

This fallback mechanism is particularly useful for:

  • Development environments with mixed-language documentation
  • Applications with incomplete translations
  • Reducing locale-related warnings

Best Practices and Tips

Use UTF-8 Encoding

Always use UTF-8 encoding for modern systems. It provides the widest character support and is the standard for internationalization.

Be Cautious with LC_ALL

Setting LC_ALL overrides all individual LC_* variables. While it ensures consistency, it can also prevent fine-grained control. Consider setting only LANG and LANGUAGE for most use cases.

User-Specific Locale Settings

If you need different locale settings for a specific user, add the locale variables to their ~/.bashrc or ~/.profile:

export LANG=en_GB.UTF-8
export LANGUAGE=en_GB:en_US

Testing Applications

After changing locales, test your critical applications to ensure they behave as expected:

# Test date formatting
date

# Test application with specific locale
LC_ALL=en_GB.UTF-8 your-application

Server Environments

For servers, especially those accessed via SSH, ensure that:

  • Required locales are installed on the server
  • SSH client doesn't force its locale settings (check /etc/ssh/sshd_config for AcceptEnv LANG LC_*)

Troubleshooting Common Issues

Issue: "locale: Cannot set LC_* to default locale"

Solution: The locale you're trying to use isn't generated. Run:

sudo locale-gen <locale-name>
sudo dpkg-reconfigure locales

Issue: Locale warnings persist after configuration

Solution:

  1. Ensure you've logged out and back in
  2. Check that locale files exist: locale -a
  3. Verify /etc/default/locale is correct
  4. Restart services that show warnings

Issue: Applications still display wrong language

Solution:

  1. Check application-specific language settings
  2. Verify that translation packages are installed (e.g., language-pack-zh-hans)
  3. Clear application cache if applicable