Create a custom locale in Linux
mouse 33 · person cloud · link
Last update
2024-12-30
2024
12-30
«USA English locale +EUR +ISO8601 dates +A4 paper»

commands

1
2
3
4
5
6
7
8
9
10
11
12
13
cp /usr/share/i18n/locales/en_US /usr/share/i18n/locales/en_US@iso8601
# integrate desired config from /usr/share/i18n/locales/it_IT

# add new entry to supported locales
mkdir -p /usr/local/share/i18n
echo "en_US@iso8601 UTF-8" >> /usr/local/share/i18n/SUPPORTED

# compile new entry
dpkg-reconfigure locales  # add en_US@iso8601 and set it as default

# test after re-login
locale  # LANG=en_US@iso8601
date    # 2024-12-30 15:32:51 CET

custom entry

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
comment_char %
escape_char /

% USA English locale +EUR +ISO8601 dates +A4 paper

LC_IDENTIFICATION
title      "English locale for the USA (+EUR +ISO8601 dates +A4 paper)"
source     "Free Software Foundation, Inc."
address    "https:////www.gnu.org//software//libc//"
contact    ""
email      "bug-glibc-locales@gnu.org"
tel        ""
fax        ""
language   "American English"
territory  "United States"
revision   "1.0"
date       "2024-12-30"

category "i18n:2012";LC_IDENTIFICATION
category "i18n:2012";LC_CTYPE
category "i18n:2012";LC_COLLATE
category "i18n:2012";LC_TIME
category "i18n:2012";LC_NUMERIC
category "i18n:2012";LC_MONETARY
category "i18n:2012";LC_MESSAGES
category "i18n:2012";LC_PAPER
category "i18n:2012";LC_NAME
category "i18n:2012";LC_ADDRESS
category "i18n:2012";LC_TELEPHONE
category "i18n:2012";LC_MEASUREMENT
END LC_IDENTIFICATION

LC_CTYPE
copy "en_GB"
END LC_CTYPE

LC_COLLATE
copy "iso14651_t1"
END LC_COLLATE

LC_MONETARY
int_curr_symbol     "EUR "
currency_symbol     "<U20AC>"
mon_decimal_point   "."
mon_thousands_sep   ","
mon_grouping        3;3
positive_sign       ""
negative_sign       "-"
int_frac_digits     2
frac_digits         2
p_cs_precedes       1
int_p_sep_by_space  1
p_sep_by_space      0
n_cs_precedes       1
int_n_sep_by_space  1
n_sep_by_space      0
p_sign_posn         1
n_sign_posn         1
END LC_MONETARY

LC_NUMERIC
decimal_point   "."
thousands_sep   ","
grouping        3;3
END LC_NUMERIC

LC_TIME
abday "Sun";"Mon";"Tue";"Wed";"Thu";"Fri";"Sat"
day   "Sunday";"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday"
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"

week  7;19971130;4
first_weekday 2
first_workday 2

% date and time representation (%c)
d_t_fmt "%F %T"

% date representation (%x)
d_fmt   "%Y-%m-%d"

% time representation (%X)
t_fmt   "%T"

% Strings for AM/PM
am_pm "AM";"PM"

% 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 "%F %T %Z"
END LC_TIME

LC_PAPER
% show current: locale -k LC_PAPER  # A4 = 297 x 210
copy "i18n"
END LC_PAPER

LC_MEASUREMENT
copy "i18n"
END LC_MEASUREMENT

LC_MESSAGES
yesexpr "^[+1yY]"
noexpr  "^[-0nN]"
yesstr  "yes"
nostr   "no"
END LC_MESSAGES

LC_NAME
name_fmt    "%d%t%g%t%m%t%f"
name_miss   "Miss."
name_mr     "Mr."
name_mrs    "Mrs."
name_ms     "Ms."
END LC_NAME

LC_ADDRESS
postal_fmt    "%a%N%f%N%d%N%b%N%h %s %e %r%N%T, %S %z%N%c%N"
country_name  "United States"
country_post  "USA"
country_ab2   "US"
country_ab3   "USA"
country_num   840
country_car   "USA"
country_isbn  0
lang_name     "English"
lang_ab       "en"
lang_term     "eng"
lang_lib      "eng"
END LC_ADDRESS

LC_TELEPHONE
tel_int_fmt    "+%c (%a) %l"
tel_dom_fmt    "(%a) %l"
int_select     "11"
int_prefix     "1"
END LC_TELEPHONE

Source: serverfault, ccollins