-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocale.sls
49 lines (43 loc) · 1.21 KB
/
locale.sls
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
{% from "node/defaults.jinja" import settings with context %}
{% set additional_list=
settings.locale.additional_lang.strip().split(' ')|join('.UTF-8 ') ~ '.UTF-8' %}
/etc/locale.conf:
file.managed:
- contents: |
LANG={{ settings.locale.lang }}
LANGUAGE={{ settings.locale.language }}
{%- if settings.locale.messages %}
LC_MESSAGES={{ settings.locale.messages }}
{%- endif %}
locales:
pkg.installed:
- pkgs:
{% if grains['os_family'] == "Debian" %}
- locales
{% elif grains['os_family'] == "Arch" %}
- glibc-locales
{% endif %}
tzdata:
pkg:
- installed
set_system_timezone:
timezone.system:
- name: {{ settings.locale.timezone }}
- utc: True
- require:
- pkg: tzdata
generate_locale:
cmd.run:
- name: locale-gen {{ settings.locale.lang }} {{ additional_list }}
- unless: |
all_locales=$(locale -a | sed -r "s/\.utf8/.UTF-8/g")
all_valid=true
for l in {{ settings.locale.lang }} {{ additional_list }}; do
if ! $(echo "$all_locales" | grep -q "$l"); then
all_valid=false
fi
done
$all_valid
- require:
- file: /etc/locale.conf
- pkg: locales