more locales

This commit is contained in:
mwiegand 2021-10-29 19:15:45 +02:00
parent f6ac34dfd0
commit 5b7c67815b
2 changed files with 23 additions and 5 deletions

View file

@ -1,8 +1,15 @@
locale = node.metadata.get('locale')
default_locale = node.metadata.get('locale/default')[0]
installed_locales = sorted([
node.metadata.get('locale/default'),
*node.metadata.get('locale/installed'),
])
files = {
'/etc/locale.gen': {
'content': f"{locale} {locale.split('.')[1]}\n",
'content': '\n'.join(
f'{locale} {type}' for locale, type in installed_locales
),
'triggers': {
'action:locale-gen',
},
@ -15,8 +22,8 @@ actions = {
'triggered': True,
},
'systemd-locale': {
'command': f'localectl set-locale LANG="{locale}"',
'unless': f'localectl | grep -Fi "system locale" | grep -Fi "{locale}"',
'command': f'localectl set-locale LANG="{default_locale}"',
'unless': f'localectl | grep -Fi "system locale" | grep -Fi "{default_locale}"',
'preceded_by': {
'action:locale-gen',
},

View file

@ -4,5 +4,16 @@ defaults = {
'locales': {},
},
},
'locale': 'en_US.UTF-8',
'locale': {
'default': ('en_US.UTF-8', 'UTF-8'),
'installed': {
('de_AT.UTF-8', 'UTF-8'),
('de_CH.UTF-8', 'UTF-8'),
('de_DE.UTF-8', 'UTF-8'),
('de_LU.UTF-8', 'UTF-8'),
('en_CA.UTF-8', 'UTF-8'),
('en_GB.UTF-8', 'UTF-8'),
('en_US.UTF-8', 'UTF-8'),
},
},
}