translate messages' description
This commit is contained in:
parent
f9a344e7a6
commit
c442abe674
@ -1,13 +1,11 @@
|
|||||||
from os.path import join, basename, dirname
|
from os import listdir
|
||||||
|
from os.path import join, basename, dirname, isfile
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
from gettext import translation
|
||||||
from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, SymLinkOption, \
|
from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, SymLinkOption, \
|
||||||
Calculation, Params, ParamOption, ParamValue, calc_value, calc_value_property_help, \
|
Calculation, Params, ParamOption, ParamValue, calc_value, calc_value_property_help, \
|
||||||
groups, Option
|
groups, Option
|
||||||
|
|
||||||
from yaml import load, SafeLoader
|
from yaml import load, SafeLoader
|
||||||
from os import listdir
|
|
||||||
from os.path import isfile
|
|
||||||
|
|
||||||
|
|
||||||
from .config import get_config
|
from .config import get_config
|
||||||
@ -16,6 +14,8 @@ from .utils import _
|
|||||||
|
|
||||||
MESSAGE_ROOT_PATH = get_config()['global']['message_root_path']
|
MESSAGE_ROOT_PATH = get_config()['global']['message_root_path']
|
||||||
groups.addgroup('message')
|
groups.addgroup('message')
|
||||||
|
MESSAGE_TRANSLATION = translation('risotto-message', join(MESSAGE_ROOT_PATH, '..', 'locale')).gettext
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DictOption(Option):
|
class DictOption(Option):
|
||||||
@ -90,6 +90,7 @@ class MessageDefinition:
|
|||||||
value = value.strip().rstrip()
|
value = value.strip().rstrip()
|
||||||
if value.endswith('.'):
|
if value.endswith('.'):
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
|
value = MESSAGE_TRANSLATION(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
# check mandatory keys
|
# check mandatory keys
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
@ -138,6 +139,7 @@ class ParameterDefinition:
|
|||||||
elif key == 'description':
|
elif key == 'description':
|
||||||
if value.endswith('.'):
|
if value.endswith('.'):
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
|
value = MESSAGE_TRANSLATION(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
# check mandatory keys
|
# check mandatory keys
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
@ -193,6 +195,7 @@ class ResponseDefinition:
|
|||||||
elif key == 'description':
|
elif key == 'description':
|
||||||
if value.endswith('.'):
|
if value.endswith('.'):
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
|
value = MESSAGE_TRANSLATION(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
# check mandatory keys
|
# check mandatory keys
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
@ -294,6 +297,7 @@ class CustomParam:
|
|||||||
elif key == 'description':
|
elif key == 'description':
|
||||||
if value.endswith('.'):
|
if value.endswith('.'):
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
|
value = MESSAGE_TRANSLATION(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
# check mandatory keys
|
# check mandatory keys
|
||||||
@ -355,6 +359,7 @@ class CustomType:
|
|||||||
elif key == 'description':
|
elif key == 'description':
|
||||||
if value.endswith('.'):
|
if value.endswith('.'):
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
|
value = MESSAGE_TRANSLATION(value)
|
||||||
|
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
# check mandatory keys
|
# check mandatory keys
|
||||||
@ -421,6 +426,7 @@ def _get_description(description,
|
|||||||
doc = name
|
doc = name
|
||||||
if doc.endswith('.'):
|
if doc.endswith('.'):
|
||||||
doc= description[:-1]
|
doc= description[:-1]
|
||||||
|
doc = MESSAGE_TRANSLATION(doc)
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user