Fix python anti patterns
This commit is contained in:
parent
5198fd8889
commit
1941b57995
@ -25,11 +25,14 @@ def load_cached_translations_file(file_name):
|
|||||||
return open(file_name).read()
|
return open(file_name).read()
|
||||||
|
|
||||||
|
|
||||||
def translate(key, variables={}):
|
def translate(key, variables=None):
|
||||||
translations = yaml.safe_load(load_cached_translations_file("translations.yaml"))
|
translations = yaml.safe_load(load_cached_translations_file("translations.yaml"))
|
||||||
value = getattr_path(translations, key)
|
value = getattr_path(translations, key)
|
||||||
|
|
||||||
if value == None:
|
if variables is None:
|
||||||
|
variables = {}
|
||||||
|
|
||||||
|
if value is None:
|
||||||
raise LocalizationInvalidKeyError(key, variables)
|
raise LocalizationInvalidKeyError(key, variables)
|
||||||
|
|
||||||
return value.format(**variables).replace("\n", "")
|
return value.format(**variables).replace("\n", "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user