Exemplo n.º 1
0
Arquivo: js.py Projeto: mbmccoy/reddit
    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)
Exemplo n.º 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)
Exemplo n.º 3
0
Arquivo: js.py Projeto: Elfmagi/reddit
 def __init__(self, lang, keys):
     DataSource.__init__(self, wrap="r.i18n.addMessages({content})")
     self.catalog = get_catalog(lang)
     self.keys = keys
Exemplo n.º 4
0
Arquivo: js.py Projeto: tomrh/reddit
 def __init__(self, lang, keys):
     DataSource.__init__(self, wrap="r.i18n.addMessages({content})")
     self.catalog = get_catalog(lang)
     self.keys = keys
Exemplo n.º 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
Exemplo n.º 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