diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py
index 0edc0e44..d4219777 100644
--- a/src/rougail/annotator.py
+++ b/src/rougail/annotator.py
@@ -75,6 +75,7 @@ KEY_TYPE = {'variable': 'symlink',
TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable')
TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable')
TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable')
+CONVERSION = {'number': int}
ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action')
@@ -685,7 +686,13 @@ class SpaceAnnotator(object):
choices = []
for value in values:
choice = self.objectspace.choice()
- choice.name = str(value)
+ try:
+ if type_ in CONVERSION:
+ choice.name = CONVERSION[type_](value)
+ else:
+ choice.name = str(value)
+ except:
+ raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"'))
choices.append(choice.name)
choice.type = type_
variable.choice.append(choice)
@@ -694,7 +701,11 @@ class SpaceAnnotator(object):
if hasattr(variable, 'value'):
for value in variable.value:
value.type = type_
- if value.name not in choices:
+ if type_ in CONVERSION:
+ cvalue = CONVERSION[type_](value.name)
+ else:
+ cvalue = value.name
+ if cvalue not in choices:
raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
else:
new_value = self.objectspace.value()
diff --git a/src/rougail/i18n.py b/src/rougail/i18n.py
index db1716c9..76758cd3 100644
--- a/src/rougail/i18n.py
+++ b/src/rougail/i18n.py
@@ -44,8 +44,8 @@ mo_location = LOCALE_DIR
gettext.find(APP_NAME, mo_location)
gettext.textdomain(APP_NAME)
-gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
-gettext.translation(APP_NAME, fallback=True)
+#gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
+#gettext.translation(APP_NAME, fallback=True)
t = gettext.translation(APP_NAME, fallback=True)
diff --git a/tests/flattener_dicos/88valid_enum_not_number/00-base.xml b/tests/flattener_dicos/88valid_enum_not_number/00-base.xml
index 36914af4..67db377c 100644
--- a/tests/flattener_dicos/88valid_enum_not_number/00-base.xml
+++ b/tests/flattener_dicos/88valid_enum_not_number/00-base.xml
@@ -17,7 +17,7 @@
- [i for i in range(3, 13)]
+ ['a', 'b', 'c']
diff --git a/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml b/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml
new file mode 100644
index 00000000..92f61c26
--- /dev/null
+++ b/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+ non
+
+
+
+
+ a
+
+
+
+
+
+
+
+ [1, 2, 3]
+
+
+
+
+ bla bla bla
+
+
+
+
diff --git a/tests/test_flattener.py b/tests/test_flattener.py
index 4e984a48..532067d5 100644
--- a/tests/test_flattener.py
+++ b/tests/test_flattener.py
@@ -83,7 +83,7 @@ def launch_flattener(test_dir, test_ok=False):
eolobj.save(destfile)
result_file = join(test_dir, 'result/00-base.xml')
if isfile(result_file):
- eolobj.save(result_file)
+ #eolobj.save(result_file)
compare_xml(destfile, result_file)
elif test_ok:
raise Exception(f'no test found for {test_dir}')