Allow setting system locales
diff --git a/README.rst b/README.rst
index fa422f7..05137aa 100644
--- a/README.rst
+++ b/README.rst
@@ -153,6 +153,18 @@
- package: '*'
action: switch
+Set system locales:
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ locale:
+ en_US.UTF-8:
+ default: true
+ cs_CZ.UTF-8:
+ enabled: true
+
Kernel
~~~~~~
diff --git a/linux/map.jinja b/linux/map.jinja
index 851c6ab..36a991c 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -6,6 +6,7 @@
'group': {},
'job': {},
'limit': {},
+ 'locale': {},
'motd': {},
'repo': {},
'package': {},
@@ -20,6 +21,7 @@
'group': {},
'job': {},
'limit': {},
+ 'locale': {},
'motd': {},
'repo': {},
'package': {},
@@ -34,6 +36,7 @@
'group': {},
'job': {},
'limit': {},
+ 'locale': {},
'motd': {},
'repo': {},
'package': {},
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 2d8517d..51e6245 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -12,7 +12,7 @@
{%- if system.kernel is defined %}
- linux.system.kernel
{%- endif %}
-{%- if system.locale is defined %}
+{%- if system.locale|length > 0 %}
- linux.system.locale
{%- endif %}
{%- if system.prompt is defined %}
diff --git a/linux/system/locale.sls b/linux/system/locale.sls
index 1b006b5..2941c17 100644
--- a/linux/system/locale.sls
+++ b/linux/system/locale.sls
@@ -1,4 +1,22 @@
{%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %}
-{%- endif %}
\ No newline at end of file
+{%- for locale_name, locale in system.locale.iteritems() %}
+{%- if locale.get('enabled', True) %}
+
+linux_locale_{{ locale_name }}:
+ locale.present:
+ - name: {{ locale_name }}
+
+{%- if locale.get('default', False) %}
+linux_locale_default:
+ locale.system:
+ - name: {{ locale_name }}
+ - require:
+ - locale: linux_locale_{{ locale_name }}
+{%- endif %}
+
+{%- endif %}
+{%- endfor %}
+
+{%- endif %}
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index 71f0f46..2e3e80d 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -71,3 +71,9 @@
action: exit 101
- package: '*'
action: switch
+ locale:
+ en_US.UTF-8:
+ enabled: true
+ default: true
+ cs_CZ.UTF-8:
+ enabled: true