Skip to content

Commit

Permalink
remove to translate text as key
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Mar 28, 2018
1 parent ea970a0 commit e8037e6
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions isogeo_pysdk/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"resourceProvider": "Fournisseur",
"user": "Utilisateur"
},
"frequencyUpdateHelp": "Tous les ",
"frequencyTypes": {
"frequencyUpdateHelp": "Tous les ",
"years": "an(s)",
"months": "mois",
"weeks": "semaine(s)",
Expand Down Expand Up @@ -154,8 +154,8 @@
"resourceProvider": "Resource provider",
"user": "User"
},
"frequencyUpdateHelp": "Every ",
"frequencyTypes": {
"frequencyUpdateHelp": "Every ",
"years": "year(s)",
"months": "month(s)",
"weeks": "week(s)",
Expand Down Expand Up @@ -210,31 +210,27 @@ def __init__(self, lang="FR"):

super(IsogeoTranslator, self).__init__()

def tr(self, subdomain=None, string_to_translate=""):
def tr(self, subdomain, string_to_translate=""):
"""Returns translation of string passed.
:param str subdomain: subpart of strings dictionary.
Must be one of self.translations.keys() i.e. 'restrictions'
:param str string_to_translate: string you want to translate
"""
if subdomain:
# check subdomain
if subdomain not in self.translations.keys():
raise ValueError("'{}' is not a correct subdomain."
" Must be one of {}"
.format(subdomain,
self.translations.keys()))
else:
pass
# translate
str_translated = self.translations.get(subdomain,
{"error": "Subdomain not found: {}"
.format(subdomain)})\
.get(string_to_translate,
"String not found")
if subdomain not in self.translations.keys():
raise ValueError("'{}' is not a correct subdomain."
" Must be one of {}"
.format(subdomain,
self.translations.keys()))
else:
str_translated = self.translations.get(string_to_translate,
"String not found")
pass
# translate
str_translated = self.translations.get(subdomain,
{"error": "Subdomain not found: {}"
.format(subdomain)})\
.get(string_to_translate,
"String not found")

# end of method
return str_translated

Expand Down

0 comments on commit e8037e6

Please sign in to comment.