From 6c6b9d2b4da9757e876ddcb87e870a1e3cb88083 Mon Sep 17 00:00:00 2001 From: Hiroshi Umehara Date: Thu, 22 Jan 2015 12:07:10 +0900 Subject: [PATCH] Generalize locale name normalization --- lib/ansible/modules/extras/system/locale_gen.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/system/locale_gen.py b/lib/ansible/modules/extras/system/locale_gen.py index edf637fecb8..a9a17e38ab1 100644 --- a/lib/ansible/modules/extras/system/locale_gen.py +++ b/lib/ansible/modules/extras/system/locale_gen.py @@ -32,6 +32,11 @@ EXAMPLES = ''' - locale_gen: name=de_CH.UTF-8 state=present ''' +LOCALE_NORMALIZATION = { + ".utf8": ".UTF-8", + ".eucjp": ".EUC-JP", +} + # =========================================== # location module specific support methods. # @@ -44,7 +49,9 @@ def is_present(name): def fix_case(name): """locale -a might return the encoding in either lower or upper case. Passing through this function makes them uniform for comparisons.""" - return name.replace(".utf8", ".UTF-8").replace(".eucjp", ".EUC-JP") + for s, r in LOCALE_NORMALIZATION.iteritems(): + name = name.replace(s, r) + return name def replace_line(existing_line, new_line): """Replaces lines in /etc/locale.gen"""