diff options
author | emkael <emkael@tlen.pl> | 2018-05-01 14:05:35 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-05-01 14:05:35 +0200 |
commit | ddf22911ae7e13f2070b164a060478f309ab09d7 (patch) | |
tree | 244fcb402cd5074249fd3fcb6fd173ee2dd45e82 /jfr_playoff/i18n.py | |
parent | 780d9f86ad66d97662bbc6908bbb5625f4317557 (diff) | |
parent | 4fa864f8b75a3865c714a2b864784b1eb85c9c1b (diff) |
Merge branch 'i18n' into devel
Diffstat (limited to 'jfr_playoff/i18n.py')
-rw-r--r-- | jfr_playoff/i18n.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/jfr_playoff/i18n.py b/jfr_playoff/i18n.py new file mode 100644 index 0000000..e22a563 --- /dev/null +++ b/jfr_playoff/i18n.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import re + +PLAYOFF_I18N_DEFAULTS = { + 'SCORE': 'wynik', + 'FINAL_STANDINGS': 'klasyfikacja końcowa', + 'STANDINGS_PLACE': 'miejsce', + 'STANDINGS_TEAM': 'drużyna', + 'STANDINGS_CAPTIONS': 'legenda', + 'FOOTER_GENERATED': 'strona wygenerowana', + 'SWISS_DEFAULT_LABEL': 'Turniej o %d. miejsce' +} + +class PlayoffI18N(object): + + def __init__(self, settings): + self.settings = settings + self.string_match = re.compile(r'{{(.*)}}') + + def localize(self, string): + return re.sub( + self.string_match, + lambda x: self.__get_translation(x.group(1)), + string) + + def __get_translation(self, string): + for dictionary in [self.settings, PLAYOFF_I18N_DEFAULTS]: + if string in dictionary: + return dictionary[string].decode('utf8') + return '{{%s}}' % (string) |