feat: translation

This commit is contained in:
egarette@silique.fr 2024-10-30 18:45:09 +01:00
parent 7b9ee39a66
commit 2400e53c01
20 changed files with 344 additions and 98 deletions

View file

@ -140,16 +140,14 @@ class Annotator(Walk):
default_variable_mode = self.default_variable_mode default_variable_mode = self.default_variable_mode
if default_variable_mode not in modes_level: if default_variable_mode not in modes_level:
msg = _( msg = _(
f'default variable mode "{default_variable_mode}" is not a valid mode, ' 'default variable mode "{0}" is not a valid mode, valid modes are {1}'
f"valid modes are {modes_level}" ).format(default_variable_mode, modes_level)
)
raise DictConsistencyError(msg, 72, None) raise DictConsistencyError(msg, 72, None)
default_family_mode = self.default_family_mode default_family_mode = self.default_family_mode
if default_family_mode not in modes_level: if default_family_mode not in modes_level:
msg = _( msg = _(
f'default family mode "{default_family_mode}" is not a valid mode, ' 'default family mode "{0}" is not a valid mode, valid modes are {1}'
f"valid modes are {modes_level}" ).format(default_family_mode, modes_level)
)
raise DictConsistencyError(msg, 73, None) raise DictConsistencyError(msg, 73, None)
families = list(self.get_families()) families = list(self.get_families())
for family in families: for family in families:
@ -180,14 +178,12 @@ class Annotator(Walk):
if self._has_mode(obj) and obj.mode not in modes_level: if self._has_mode(obj) and obj.mode not in modes_level:
if modes_level: if modes_level:
msg = _( msg = _(
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, ' 'mode "{0}" for "{1}" is not a valid mode, valid modes are {2}'
f"valid modes are {modes_level}" ).format(obj.mode, obj.name, modes_level)
)
else: else:
msg = _( msg = _(
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, ' 'mode "{0}" for "{1}" is not a valid mode, no modes are available'
f"no modes are available" ).format(obj.mode, obj.name)
)
raise DictConsistencyError(msg, 71, obj.xmlfiles) raise DictConsistencyError(msg, 71, obj.xmlfiles)
def _set_default_mode( def _set_default_mode(
@ -250,9 +246,8 @@ class Annotator(Walk):
and self.modes[variable_mode] < self.modes[family_mode] and self.modes[variable_mode] < self.modes[family_mode]
): ):
msg = _( msg = _(
f'the variable "{variable.name}" is mandatory so in "{variable_mode}" mode ' 'the variable "{0}" is mandatory so in "{1}" mode but family has the higher family mode "{2}"'
f'but family has the higher family mode "{family_mode}"' ).format(variable.name, variable_mode, family_mode)
)
raise DictConsistencyError(msg, 36, variable.xmlfiles) raise DictConsistencyError(msg, 36, variable.xmlfiles)
variable.mode = variable_mode variable.mode = variable_mode
@ -289,9 +284,8 @@ class Annotator(Walk):
# leader's mode is minimum level # leader's mode is minimum level
if self._has_mode(follower): if self._has_mode(follower):
msg = _( msg = _(
f'the follower "{follower.name}" is in "{follower_mode}" mode ' 'the follower "{0}" is in "{1}" mode but leader have the higher mode "{2}"'
f'but leader have the higher mode "{leader.mode}"' ).format(follower.name, follower_mode, leader.mode)
)
raise DictConsistencyError(msg, 63, follower.xmlfiles) raise DictConsistencyError(msg, 63, follower.xmlfiles)
self._set_auto_mode(follower, leader.mode) self._set_auto_mode(follower, leader.mode)
@ -323,9 +317,8 @@ class Annotator(Walk):
self._set_auto_mode(family, min_variable_mode) self._set_auto_mode(family, min_variable_mode)
if self.modes[family.mode] < self.modes[min_variable_mode]: if self.modes[family.mode] < self.modes[min_variable_mode]:
msg = _( msg = _(
f'the family "{family.name}" is in "{family.mode}" mode but variables and ' 'the family "{0}" is in "{1}" mode but variables and families inside have the higher modes "{2}"'
f'families inside have the higher modes "{min_variable_mode}"' ).format(family.name, family.mode, min_variable_mode)
)
raise DictConsistencyError(msg, 62, family.xmlfiles) raise DictConsistencyError(msg, 62, family.xmlfiles)
def _change_variable_mode( def _change_variable_mode(
@ -342,9 +335,8 @@ class Annotator(Walk):
if not is_follower and self.modes[variable_mode] < self.modes[family_mode]: if not is_follower and self.modes[variable_mode] < self.modes[family_mode]:
if self._has_mode(variable): if self._has_mode(variable):
msg = _( msg = _(
f'the variable "{variable.name}" is in "{variable_mode}" mode ' 'the variable "{0}" is in "{1}" mode but family has the higher family mode "{2}"'
f'but family has the higher family mode "{family_mode}"' ).format(variable.name, variable_mode, family_mode)
)
raise DictConsistencyError(msg, 61, variable.xmlfiles) raise DictConsistencyError(msg, 61, variable.xmlfiles)
self._set_auto_mode(variable, family_mode) self._set_auto_mode(variable, family_mode)
if not variable.mode: if not variable.mode:

View file

@ -78,8 +78,8 @@ class Annotator(Walk): # pylint: disable=R0903
raise DictConsistencyError(msg, 68, variable.xmlfiles) raise DictConsistencyError(msg, 68, variable.xmlfiles)
if variable.path in self.objectspace.followers and multi != "submulti": if variable.path in self.objectspace.followers and multi != "submulti":
msg = _( msg = _(
f'the follower "{variable.name}" without multi attribute can only have one value' 'the follower "{0}" without multi attribute can only have one value'
) ).format(variable.name)
raise DictConsistencyError(msg, 87, variable.xmlfiles) raise DictConsistencyError(msg, 87, variable.xmlfiles)
if not variable.default: if not variable.default:
variable.default = None variable.default = None
@ -94,8 +94,8 @@ class Annotator(Walk): # pylint: disable=R0903
) )
elif variable.multi: elif variable.multi:
msg = _( msg = _(
f'the variable "{variable.name}" is multi but has a non list default value' 'the variable "{0}" is multi but has a non list default value'
) ).format(variable.name)
raise DictConsistencyError(msg, 12, variable.xmlfiles) raise DictConsistencyError(msg, 12, variable.xmlfiles)
elif variable.path in self.objectspace.followers: elif variable.path in self.objectspace.followers:
self.objectspace.default_multi[variable.path] = variable.default self.objectspace.default_multi[variable.path] = variable.default

View file

@ -190,8 +190,8 @@ class Annotator(Walk): # pylint: disable=R0903
variable.hidden = None variable.hidden = None
if variable.regexp is not None and variable.type != "regexp": if variable.regexp is not None and variable.type != "regexp":
msg = _( msg = _(
f'the variable "{variable.path}" has regexp attribut but has not the "regexp" type' 'the variable "{0}" has regexp attribut but has not the "regexp" type'
) ).format(variable.path)
raise DictConsistencyError(msg, 37, variable.xmlfiles) raise DictConsistencyError(msg, 37, variable.xmlfiles)
if variable.mandatory is None: if variable.mandatory is None:
variable.mandatory = True variable.mandatory = True
@ -233,8 +233,8 @@ class Annotator(Walk): # pylint: disable=R0903
variable.type = "choice" variable.type = "choice"
if variable.choices is not None and variable.type != "choice": if variable.choices is not None and variable.type != "choice":
msg = _( msg = _(
f'the variable "{variable.path}" has choices attribut but has not the "choice" type' 'the variable "{0}" has choices attribut but has not the "choice" type'
) ).format(variable.path)
raise DictConsistencyError(msg, 11, variable.xmlfiles) raise DictConsistencyError(msg, 11, variable.xmlfiles)
if variable.type != "choice": if variable.type != "choice":
continue continue
@ -261,6 +261,6 @@ class Annotator(Walk): # pylint: disable=R0903
continue continue
if value not in choices: if value not in choices:
msg = _( msg = _(
f'the variable "{variable.path}" has an unvalid default value "{value}" should be in {display_list(choices, separator="or", add_quote=True)}' 'the variable "{0}" has an unvalid default value "{1}" should be in {2}'
) ).format(variable.path, value, display_list(choices, separator="or", add_quote=True))
raise DictConsistencyError(msg, 26, variable.xmlfiles) raise DictConsistencyError(msg, 26, variable.xmlfiles)

View file

@ -55,7 +55,6 @@ from warnings import warn
from tiramisu.error import display_list from tiramisu.error import display_list
from .annotator import SpaceAnnotator from .annotator import SpaceAnnotator
from .error import DictConsistencyError
from .i18n import _ from .i18n import _
from .object_model import CONVERT_OPTION # Choice, from .object_model import CONVERT_OPTION # Choice,
from .object_model import ( from .object_model import (
@ -267,9 +266,8 @@ class Paths:
and namespace != option_namespace and namespace != option_namespace
): ):
msg = _( msg = _(
f'A variable or a family located in the "{option_namespace}" namespace ' 'A variable or a family located in the "{0}" namespace shall not be used in the "{1}" namespace'
f'shall not be used in the "{namespace}" namespace' ).format(option_namespace, namespace)
)
raise DictConsistencyError(msg, 38, xmlfiles) raise DictConsistencyError(msg, 38, xmlfiles)
return option, identifiers return option, identifiers
@ -461,7 +459,7 @@ class ParserVariable:
return "family" return "family"
if obj_type in self.variable_types: if obj_type in self.variable_types:
return "variable" return "variable"
msg = f"unknown type {obj_type} for {path}" msg = _("unknown type {0} for {1}").format(obj_type, path)
raise DictConsistencyError(msg, 43, [filename]) raise DictConsistencyError(msg, 43, [filename])
# in a leadership there is only variable # in a leadership there is only variable
if family_is_leadership: if family_is_leadership:
@ -472,7 +470,7 @@ class ParserVariable:
extra_keys = set(obj) - self.variable_attrs extra_keys = set(obj) - self.variable_attrs
if not extra_keys: if not extra_keys:
for key, value in obj.items(): for key, value in obj.items():
if isinstance(value, dict) and not self.is_calculation( if isinstance(value, dict) and key != 'params' and not self.is_calculation(
key, key,
value, value,
self.variable_calculations, self.variable_calculations,
@ -1322,7 +1320,7 @@ class RougailConvert(ParserVariable):
continue continue
if file_path.name in filenames: if file_path.name in filenames:
raise DictConsistencyError( raise DictConsistencyError(
_(f"duplicate dictionary file name {file_path.name}"), _("duplicate dictionary file name {0}").format(file_path.name),
78, 78,
[filenames[file_path.name][1]], [filenames[file_path.name][1]],
) )

View file

@ -67,7 +67,7 @@ class DictConsistencyError(Exception):
def __init__(self, msg, errno, xmlfiles): def __init__(self, msg, errno, xmlfiles):
if xmlfiles: if xmlfiles:
msg = _(f"{msg} in {display_xmlfiles(xmlfiles)}") msg = _("{0} in {1}").format(msg, display_xmlfiles(xmlfiles))
super().__init__(msg) super().__init__(msg)
self.errno = errno self.errno = errno

View file

@ -27,35 +27,9 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import gettext from gettext import translation
import os from pathlib import Path
import sys
import locale
# Application Name t = translation('rougail', str(Path(__file__).parent / 'locale'))
APP_NAME = "rougail"
# Traduction dir
APP_DIR = os.path.join(sys.prefix, "share")
LOCALE_DIR = os.path.join(APP_DIR, "locale")
# Default Lanugage
DEFAULT_LANG = os.environ.get("LANG", "").split(":")
DEFAULT_LANG += ["en_US"]
languages = []
lc, encoding = locale.getlocale()
if lc:
languages = [lc]
languages += DEFAULT_LANG
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)
t = gettext.translation(APP_NAME, fallback=True)
_ = t.gettext _ = t.gettext

Binary file not shown.

View file

@ -0,0 +1,166 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2024-10-30 13:21+0100\n"
"PO-Revision-Date: 2024-10-30 13:39+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.5\n"
#: src/rougail/annotator/family.py:142
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
"le mode d'une variable par défaut \"{0}\" n'est pas un mode valide, les "
"modes valides sont {1}"
#: src/rougail/annotator/family.py:148
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
"le mode d'une famille par défaut \"{0}\" n'est pas un mode valide, les modes "
"valides sont {1}"
#: src/rougail/annotator/family.py:180
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
msgstr ""
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, les modes valides "
"sont {2}"
#: src/rougail/annotator/family.py:184
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
msgstr ""
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, aucun mode ne sont "
"définis"
#: src/rougail/annotator/family.py:248
msgid ""
"the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the "
"higher family mode \"{2}\""
msgstr ""
"la variable \"{0}\" est obligatoire donc dans le mode \"{1}\" mais la "
"famille a un mode supérieur \"{2}\""
#: src/rougail/annotator/family.py:286
msgid ""
"the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode "
"\"{2}\""
msgstr ""
"la variable suiveuse \"{0}\" a le mode \"{1}\" mais la variable leader a un "
"mode supérieur \"{2}\""
#: src/rougail/annotator/family.py:319
msgid ""
"the family \"{0}\" is in \"{1}\" mode but variables and families inside have "
"the higher modes \"{2}\""
msgstr ""
"la famille \"{0}\" a le mode \"{1}\" mais les variables et les familles à "
"l'intérieur ont des modes supérieurs \"{2}\""
#: src/rougail/annotator/family.py:337
msgid ""
"the variable \"{0}\" is in \"{1}\" mode but family has the higher family "
"mode \"{2}\""
msgstr ""
"la variable \"{0}\" est dans le mode \"{1}\" mais la famille a le mode "
"supérieur \"{2}\""
#: src/rougail/annotator/value.py:80
msgid "the follower \"{0}\" without multi attribute can only have one value"
msgstr ""
"la variable suiveuse \"{0}\" sans l'attribut multi peut avoir seulement une "
"valeur"
#: src/rougail/annotator/value.py:96
msgid "the variable \"{0}\" is multi but has a non list default value"
msgstr ""
"la variable \"{0}\" est multiple mais a une valeur par défaut sans être une "
"liste"
#: src/rougail/annotator/variable.py:192
msgid ""
"the variable \"{0}\" has regexp attribut but has not the \"regexp\" type"
msgstr ""
"la variable \"{0}\" a un attribut regexp mais n'a pas le type \"regexp\""
#: src/rougail/annotator/variable.py:235
msgid ""
"the variable \"{0}\" has choices attribut but has not the \"choice\" type"
msgstr ""
"la variable \"{0}\" a un attribut choices mais n'a pas le type \"choice\""
#: src/rougail/annotator/variable.py:263
msgid ""
"the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
msgstr ""
"la variable \"{0}\" a la valeur par défaut invalide \"{1}\" devrait être {2}"
#: src/rougail/convert.py:268
msgid ""
"A variable or a family located in the \"{0}\" namespace shall not be used in "
"the \"{1}\" namespace"
msgstr ""
"Une variable ou une famille localisé dans l'espace de nom \"{0}\" ne devrait "
"pas être utilisé dans l'espace de nom \"{1}\""
#: src/rougail/convert.py:462
msgid "unknown type {0} for {1}"
msgstr "type {0} inconnu pour {1}"
#: src/rougail/convert.py:1323
msgid "duplicate dictionary file name {0}"
msgstr "nom de fichier {0} de dictionnaire dupliqué"
#: src/rougail/convert.py:1370
msgid "Cannot execute annotate multiple time"
msgstr "Ne peut exécuter l'annotation plusieurs fois"
#: src/rougail/error.py:70
msgid "{0} in {1}"
msgstr "{0} dans {1}"
#: src/rougail/structural_commandline/annotator.py:70
msgid "alternative_name \"{0}\" conflict with \"--help\""
msgstr "alternative_name \"{0}\" est en conflit avec \"--help\""
#: src/rougail/structural_commandline/annotator.py:73
msgid "conflict alternative_name \"{0}\": \"{1}\" and \"{2}\""
msgstr "conflit dans les \"alternative_name\" \"{0}\": \"{1}\" et \"{2}\""
#: src/rougail/structural_commandline/annotator.py:96
msgid ""
"negative_description is mandatory for boolean variable, but \"{0}\" hasn't"
msgstr ""
"l'attribut negative_description est obligatoire pour des variables "
"\"boolean\", mais \"{0}\" n'en a pas"
#: src/rougail/structural_commandline/annotator.py:105
msgid ""
"negative_description is only available for boolean variable, but \"{0}\" is "
"\"{1}\""
msgstr ""
"l'attribut negative_description est seulement valide pour des variables "
"\"boolean\", mais \"{0}\" est \"{1}\""
#: src/rougail/update/update.py:741
msgid "not a XML file: {0}"
msgstr "fichier XML invalid : {0}"
#: src/rougail/utils.py:58
msgid ""
"invalid variable or family name \"{0}\" must only contains lowercase ascii "
"character, number or _"
msgstr ""
"nom invalide pour la variable ou famille \"{0}\" doit seulement contenir des "
"caractères ascii minuscule, nombre or _"
#: src/rougail/utils.py:120
msgid "error in jinja \"{0}\" for the variable \"{1}\": {2}"
msgstr "erreur dans Jinja \"{0}\" pour la variable \"{1}\": {2}"

View file

@ -0,0 +1,117 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-10-30 13:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: src/rougail/annotator/family.py:142
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
#: src/rougail/annotator/family.py:148
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
#: src/rougail/annotator/family.py:180
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
msgstr ""
#: src/rougail/annotator/family.py:184
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
msgstr ""
#: src/rougail/annotator/family.py:248
msgid "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:286
msgid "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:319
msgid "the family \"{0}\" is in \"{1}\" mode but variables and families inside have the higher modes \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:337
msgid "the variable \"{0}\" is in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr ""
#: src/rougail/annotator/value.py:80
msgid "the follower \"{0}\" without multi attribute can only have one value"
msgstr ""
#: src/rougail/annotator/value.py:96
msgid "the variable \"{0}\" is multi but has a non list default value"
msgstr ""
#: src/rougail/annotator/variable.py:192
msgid "the variable \"{0}\" has regexp attribut but has not the \"regexp\" type"
msgstr ""
#: src/rougail/annotator/variable.py:235
msgid "the variable \"{0}\" has choices attribut but has not the \"choice\" type"
msgstr ""
#: src/rougail/annotator/variable.py:263
msgid "the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
msgstr ""
#: src/rougail/convert.py:268
msgid "A variable or a family located in the \"{0}\" namespace shall not be used in the \"{1}\" namespace"
msgstr ""
#: src/rougail/convert.py:462
msgid "unknown type {0} for {1}"
msgstr ""
#: src/rougail/convert.py:1323
msgid "duplicate dictionary file name {0}"
msgstr ""
#: src/rougail/convert.py:1370
msgid "Cannot execute annotate multiple time"
msgstr ""
#: src/rougail/error.py:70
msgid "{0} in {1}"
msgstr ""
#: src/rougail/structural_commandline/annotator.py:70
msgid "alternative_name \"{0}\" conflict with \"--help\""
msgstr ""
#: src/rougail/structural_commandline/annotator.py:73
msgid "conflict alternative_name \"{0}\": \"{1}\" and \"{2}\""
msgstr ""
#: src/rougail/structural_commandline/annotator.py:96
msgid "negative_description is mandatory for boolean variable, but \"{0}\" hasn't"
msgstr ""
#: src/rougail/structural_commandline/annotator.py:105
msgid "negative_description is only available for boolean variable, but \"{0}\" is \"{1}\""
msgstr ""
#: src/rougail/update/update.py:741
msgid "not a XML file: {0}"
msgstr ""
#: src/rougail/utils.py:58
msgid "invalid variable or family name \"{0}\" must only contains lowercase ascii character, number or _"
msgstr ""
#: src/rougail/utils.py:120
msgid "error in jinja \"{0}\" for the variable \"{1}\": {2}"
msgstr ""

View file

@ -67,12 +67,12 @@ class Annotator(Walk):
for letter in alternative_name: for letter in alternative_name:
all_letters += letter all_letters += letter
if all_letters == "h": if all_letters == "h":
msg = _(f'alternative_name "{alternative_name}" conflict with "--help"') msg = _('alternative_name "{0}" conflict with "--help"').format(alternative_name)
raise DictConsistencyError(msg, 202, variable.xmlfiles) raise DictConsistencyError(msg, 202, variable.xmlfiles)
if all_letters in self.alternative_names: if all_letters in self.alternative_names:
msg = _( msg = _(
f'conflict alternative_name "{alternative_name}": "{variable_path}" and "{self.alternative_names[all_letters]}"' 'conflict alternative_name "{0}": "{1}" and "{2}"'
) ).format(alternative_name, variable_path, self.alternative_names[all_letters])
raise DictConsistencyError(msg, 202, variable.xmlfiles) raise DictConsistencyError(msg, 202, variable.xmlfiles)
self.alternative_names[alternative_name] = variable_path self.alternative_names[alternative_name] = variable_path
@ -94,8 +94,8 @@ class Annotator(Walk):
if variable.type == "boolean" and not self.objectspace.add_extra_options: if variable.type == "boolean" and not self.objectspace.add_extra_options:
raise DictConsistencyError( raise DictConsistencyError(
_( _(
f'negative_description is mandatory for boolean variable, but "{variable.path}" hasn\'t' 'negative_description is mandatory for boolean variable, but "{0}" hasn\'t'
), ).format(variable.path),
200, 200,
variable.xmlfiles, variable.xmlfiles,
) )
@ -103,8 +103,8 @@ class Annotator(Walk):
if variable.type != "boolean": if variable.type != "boolean":
raise DictConsistencyError( raise DictConsistencyError(
_( _(
f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"' 'negative_description is only available for boolean variable, but "{0}" is "{1}"'
), ).format(variable.path, variable.type),
201, 201,
variable.xmlfiles, variable.xmlfiles,
) )

View file

@ -738,7 +738,7 @@ class RougailUpgrade:
parser = XMLParser(remove_blank_text=True) parser = XMLParser(remove_blank_text=True)
document = parse(xmlsrc, parser) document = parse(xmlsrc, parser)
except XMLSyntaxError as err: except XMLSyntaxError as err:
raise Exception(_(f"not a XML file: {err}")) from err raise Exception(_("not a XML file: {0}").format(err)) from err
root = document.getroot() root = document.getroot()
search_function_name = get_function_name( search_function_name = get_function_name(
root.attrib.get("version", "1") root.attrib.get("version", "1")

View file

@ -56,9 +56,8 @@ def valid_variable_family_name(
match = NAME_REGEXP.search(name) match = NAME_REGEXP.search(name)
if not match: if not match:
msg = _( msg = _(
f'invalid variable or family name "{name}" must only contains ' 'invalid variable or family name "{0}" must only contains lowercase ascii character, number or _'
"lowercase ascii character, number or _" ).format(name)
)
raise DictConsistencyError(msg, 76, xmlfiles) raise DictConsistencyError(msg, 76, xmlfiles)
@ -119,8 +118,8 @@ def get_jinja_variable_to_param(
variables.add(recurse_getattr(g)) variables.add(recurse_getattr(g))
except TemplateSyntaxError as err: except TemplateSyntaxError as err:
msg = _( msg = _(
f'error in jinja "{jinja_text}" for the variable "{ current_path }": {err}' 'error in jinja "{0}" for the variable "{1}": {2}'
) ).format(jinja_text, current_path, err)
raise DictConsistencyError(msg, 39, xmlfiles) from err raise DictConsistencyError(msg, 39, xmlfiles) from err
variables = list(variables) variables = list(variables)
variables.sort(reverse=True) variables.sort(reverse=True)

View file

@ -2,7 +2,7 @@
version: '1.1' version: '1.1'
int: int:
description: A limited number description: A limited number
type: number default: 10
params: params:
min_number: 0 min_number: 0
max_number: 100 max_number: 100

View file

@ -1,6 +1,6 @@
{ {
"rougail.int": { "rougail.int": {
"owner": "default", "owner": "default",
"value": null "value": 10
} }
} }

View file

@ -1,3 +1,3 @@
{ {
"rougail.int": null "rougail.int": 10
} }

View file

@ -1,6 +1,6 @@
{ {
"rougail.int": { "rougail.int": {
"owner": "default", "owner": "default",
"value": null "value": 10
} }
} }

View file

@ -1 +1 @@
["rougail.int"] []

View file

@ -10,6 +10,6 @@ except:
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = IntOption(name="int", doc="A limited number", min_number=0, max_number=100, properties=frozenset({"basic", "mandatory"}), informations={'type': 'number'}) option_2 = IntOption(name="int", doc="A limited number", default=10, min_number=0, max_number=100, properties=frozenset({"mandatory", "standard"}), informations={'type': 'number'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"basic"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -10,10 +10,10 @@ except:
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_3 = IntOption(name="int", doc="A limited number", min_number=0, max_number=100, properties=frozenset({"basic", "mandatory"}), informations={'type': 'number'}) option_3 = IntOption(name="int", doc="A limited number", default=10, min_number=0, max_number=100, properties=frozenset({"mandatory", "standard"}), informations={'type': 'number'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_3], properties=frozenset({"basic"})) optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_3], properties=frozenset({"standard"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"})) optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
option_6 = IntOption(name="int", doc="A limited number", min_number=0, max_number=100, properties=frozenset({"basic", "mandatory"}), informations={'type': 'number'}) option_6 = IntOption(name="int", doc="A limited number", default=10, min_number=0, max_number=100, properties=frozenset({"mandatory", "standard"}), informations={'type': 'number'})
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_6], properties=frozenset({"basic"})) optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_6], properties=frozenset({"standard"}))
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"basic"})) optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])

View file

@ -6,5 +6,5 @@ load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = IntOption(name="int", doc="A limited number", min_number=0, max_number=100, properties=frozenset({"basic", "mandatory"}), informations={'type': 'number'}) option_1 = IntOption(name="int", doc="A limited number", default=10, min_number=0, max_number=100, properties=frozenset({"mandatory", "standard"}), informations={'type': 'number'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])