Пример #1
0
    def get_localized_source(self, lang):
        catalog = get_catalog(lang)

        # relies on pyx files, so it can't be imported at global scope
        from r2.lib.utils import tup

        data = {}
        for key in self.keys:
            key = tup(key)[0]  # because the key for plurals is (sing, plur)
            self._check_formatting_specifiers(key)
            msg = catalog[key]

            if not msg or not msg.string:
                continue

            # jed expects to ignore the first value in the translations array
            # so we'll just make it null
            strings = tup(msg.string)
            data[key] = [None] + list(strings)
        return "r.i18n.addMessages(%s)" % json.dumps(data)
Пример #2
0
    def get_localized_source(self, lang):
        catalog = get_catalog(lang)

        # relies on pyx files, so it can't be imported at global scope
        from r2.lib.utils import tup

        data = {}
        for key in self.keys:
            key = tup(key)[0]  # because the key for plurals is (sing, plur)
            self._check_formatting_specifiers(key)
            msg = catalog[key]

            if not msg or not msg.string:
                continue

            # jed expects to ignore the first value in the translations array
            # so we'll just make it null
            strings = tup(msg.string)
            data[key] = [None] + list(strings)
        return "r.i18n.addMessages(%s)" % json.dumps(data)
Пример #3
0
 def __init__(self, lang, keys):
     DataSource.__init__(self, wrap="r.i18n.addMessages({content})")
     self.catalog = get_catalog(lang)
     self.keys = keys
Пример #4
0
Файл: js.py Проект: tomrh/reddit
 def __init__(self, lang, keys):
     DataSource.__init__(self, wrap="r.i18n.addMessages({content})")
     self.catalog = get_catalog(lang)
     self.keys = keys
Пример #5
0
 def get_localized_source(self, lang):
     catalog = get_catalog(lang)
     validate_plural_forms(catalog.plural_expr)
     return "r.i18n.setPluralForms('%s')" % catalog.plural_expr
Пример #6
0
 def get_localized_source(self, lang):
     catalog = get_catalog(lang)
     validate_plural_forms(catalog.plural_expr)
     return "r.i18n.setPluralForms('%s')" % catalog.plural_expr