Linux: setlocale: LC_ALL: cannot change locale (en_US.utf8) and Cyrillic symbols
Tags: linux, todayileanded
Published: 2021-04-19 08:23:42

---
title: Linux: setlocale: LC_ALL: cannot change locale (en_US.utf8) and Cyrillic symbols
published: true
date: 2021-02-04 08:55:12 UTC
tags: linux,todayileanded
canonical_url: https://rtfm.co.ua/en/linux-setlocale-lc_all-cannot-change-locale-en_us-utf8-and-cyrillic-symbols/
---

![](https://cdn-images-1.medium.com/max/505/1*M8WP_RFKNaqRLSujd9Ik3w.png)

Locales is a set of environment variables that are used to determine how to display data and time (for example, first of the week), symbols encoding (for example, how to display cyrillic symbols), default files order when one executing the ls command, and so on.

Those variables are:

- `LANG`: Determines the default locale in the absence of other locale related environment variables
- `LANGUAGE`: List of fallback message translation languages
- `LC_CTYPE`: Character classification and case conversion
- `LC_NUMERIC`: Numeric formatting
- `LC_TIME`: Date and time formats
- `LC_COLLATE`: Collation (sort) order
- `LC_MONETARY`: Monetary formatting
- `LC_MESSAGES`: Format of interactive words and responses
- `LC_PAPER`: Default paper size for region
- `LC_NAME`: Name formats
- `LC_ADDRESS`: Convention used for formatting of street or postal addresses
- `LC_TELEPHONE`: Conventions used for representation of telephone numbers
- `LC_MEASUREMENT`: Default measurement system used within the region
- `LC_IDENTIFICATION`: Metadata about the locale information
- `LC_RESPONSE`: Determines how responses (such as Yes and No) appear in the local language (not in use by Debian GNU/Linux but Ubuntu)
- `LC_ALL`: Overrides all other locale variables (except `LANGUAGE`)

### Locale and Cyrillic symbols

For example, when running a [`vifm`](https://vifm.info/manual.shtml) tool in the KDE Konsole on my Arch Linux - cyrillic symbols are not displayed correctly:

![](https://cdn-images-1.medium.com/max/955/0*gly-tX7g0FS3R22d.png)

And after exiting from the [vifm](https://vifm.info/manual.shtml) terminal produces an error message:

```
$ vifm
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
```

### Generate Locale

Check the `/usr/lib/locale/` where already generated locales must be stored - nothing here now:

```
$ ll /usr/lib/locale/
total 0
```

Or you can check by calling the `locale -a` to display locales that are available in the system now:

```
$ locale -a
C
POSIX
```

Now, to add a new locale edit the `locales.gen` - find `en_US.UTF-8`:

```
$ cat /etc/locale.gen | grep en_US.UTF-8
en_US.UTF-8 UTF-8
en_US.UTF-8 UTF-8
```

Uncomment the `en_US.UTF-8 UTF-8` string and run locales generator:

```
$ sudo locale-gen
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
Generating locales…
en_US.UTF-8… done
Generation complete.
```

Check the directory again:

```
$ file /usr/lib/locale/locale-archive
/usr/lib/locale/locale-archive: locale archive 11 strings
```

And `locale -a` again:

```
$ locale -a
C
en_US.utf8
POSIX
```

Or by using the `localedef` utility:

```
$ localedef — list-archive
en_US.utf8
```

And run the `vifm` again:

![](https://cdn-images-1.medium.com/max/955/0*IYUVconvlPyFoPHQ.png)

### Locales parameters

You can check various parameters for a specific locale by calling `locale -k`:

```
$ locale -k LC_TIME
abday=”Sun;Mon;Tue;Wed;Thu;Fri;Sat”
day=”Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday”
…
first_weekday=1
first_workday=2
```

Locales are described in a corresponding file in the `/usr/share/i18n/locales/` catalog which is used during locale-gen. For example, for the _en_US_ its `LC_TIME` locale is described as:

```
LC_TIME
abday "Sun";"Mon";"Tue";"Wed";"Thu";"Fri";"Sat"
day "Sunday";/
        "Monday";/
        "Tuesday";/
        "Wednesday";/
        "Thursday";/
        "Friday";/
        "Saturday"

week 7;19971130;1
abmon "Jan";"Feb";/
        "Mar";"Apr";/
        "May";"Jun";/
        "Jul";"Aug";/
        "Sep";"Oct";/
        "Nov";"Dec"
mon "January";/
        "February";/
        "March";/
        "April";/
        "May";/
        "June";/
        "July";/
        "August";/
        "September";/
        "October";/
        "November";/
        "December"
% Appropriate date and time representation (%c)
d_t_fmt "%a %d %b %Y %r %Z"
%
% Appropriate date representation (%x)
d_fmt "%m//%d//%Y"
%
% Appropriate time representation (%X)
t_fmt "%r"
%
% Appropriate AM/PM time representation (%r)
t_fmt_ampm "%I:%M:%S %p"
%
% Appropriate date and time representation for date(1). This is
% different from d_t_fmt for historical reasons and has been different
% since 2000 when date_fmt was added as a GNU extension. At the end
% of 2018 it was adjusted to use 12H time (bug 24046) instead of 24H.
date_fmt "%a %b %e %r %Z %Y"
%
% Strings for AM/PM
%
am_pm "AM";"PM"
END LC_TIME
```

And for the _ru_RU_ its `LC_TIME` has the `first_weekday` option set, see [`man 5 locale`](https://man7.org/linux/man-pages/man5/locale.5.html), which specifies the first day of the week - Monday (which is second in the list):

```
...
week 7;19971130;1
first_weekday 2
END LC_TIME
...
```

To set Monday as the first day of the week, set the LC_TIME as _ru_RU.UTF-8_ in the `/etc/locale.conf` file. At first, uncomment it in the `/etc/locale.gen` and then execute the `locale-gen`:

```
LANG=en_US.UTF-8
LC_TIME=ru_RU.UTF-8
```

Or by using the `localectl` tool:

```
$ localectl set-locale LC_TIME=ru_RU.UTF-8
```

### Useful links

- [Locale](https://wiki.archlinux.org/index.php/Locale) on the Arch Wiki
- [Understanding the Locales on Debian GNU/Linux](https://linuxhint.com/locales_debian/)

_Originally published at_ [_RTFM: Linux, DevOps and system administration_](https://rtfm.co.ua/en/linux-setlocale-lc_all-cannot-change-locale-en_us-utf8-and-cyrillic-symbols/)_._

* * *