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