Added more docstrings for libraries

This commit is contained in:
Antonio de la Rosa 2022-03-14 00:04:30 +01:00
parent 58ff6a1d74
commit 799cfe2125
4 changed files with 140 additions and 15 deletions

View file

@ -10,6 +10,8 @@ yes_session=False
i18n_module={}
def load_lang(*args):
"""A function for load the lang module dinamically
"""
for module in args:
@ -28,6 +30,15 @@ def load_lang(*args):
class I18n:
"""Class for i18n tasks
Class for i18n tasks, how, strings for every language supported, for now are en-US and es-ES. You can add more languages adding
Attributes:
default_lang (str): The default string lang used when get someone
dict_i18n (list): The list with default languages. You can add more calling it static variable in settings/config.py
"""
default_lang='en-US'
@ -42,6 +53,7 @@ class I18n:
@staticmethod
def get_default_lang():
"""Static method for get the default lang"""
lang=I18n.default_lang
@ -52,11 +64,19 @@ class I18n:
@staticmethod
def lang(module, symbol, text_default):
"""Static method for get a string from selected language
Static method used to get the string of the selected language. If there is no string in the selected language, it returns text_default.
Args:
module (str): The module to which the translation string belongs
symbol (str): Simple symbol that is useful for identify the string
text_default (str): The text used by default when there are not translation in the selected language
"""
if not lang:
lang=I18n.get_default_lang()
"""
#if not lang:
# lang=I18n.get_default_lang()
lang=I18n.get_default_lang()
I18n.l[lang]=I18n.l.get(lang, {})
@ -69,6 +89,11 @@ class I18n:
@staticmethod
def extract_value(value):
"""Static method for get values from json lang array
Args:
value (json): Lang dict in json format
"""
value=json.loads(value)
@ -88,6 +113,15 @@ class I18n:
"""
@staticmethod
def lang_json(module, symbol, text_default):
"""Static method for return a language dict in JSON
Static method used to get the string of the selected language in JSON format. If there are not string in the selected language, it returns text_default.
Args:
module (str): The module to which the translation string belongs
symbol (str): Simple symbol that is useful for identify the string
text_default (str): The text used by default when there are not translation in the selected language
"""
arr_final={}