Exemple #1
0
 def run(self):
 
     import os, shutil, errno
     PO_DIR = join(WHERE_AM_I, 'po')
     LOCALE_DIR = join(WHERE_AM_I, 'locale')
     locales = []
     for file in os.listdir(PO_DIR):
         if file.endswith(".po"):
             locales.append(os.path.basename(file)[:-3])
     print(locales)
     filename = '%s.po' % self.distribution.get_name()
     for locale in locales:
         po_PO = join(PO_DIR, locale + '.po')
         lc_messages_dir = join(LOCALE_DIR, locale)
         lc_messages_dir = join(lc_messages_dir, 'LC_MESSAGES')
         if not os.path.exists(LOCALE_DIR):
             os.mkdir(LOCALE_DIR)
         if not os.path.exists(join(LOCALE_DIR, locale)):
             os.mkdir(join(LOCALE_DIR, locale))
         if not os.path.exists(lc_messages_dir):
             os.mkdir(lc_messages_dir)
         po_LOCALE = join(lc_messages_dir, filename) 
         shutil.copy(po_PO,po_LOCALE)
 
     # python setup.py compile_catalog --directory locale
     
     compiler = babel.compile_catalog(self.distribution)
     compiler.directory = LOCALE_DIR
     compiler.domain = self.distribution.get_name()
     compiler.run()
def run() -> None:
    api_key = configuration.get('poeditor_api_key')
    if api_key is None:
        logger.warning('Missing poeditor.com API key')
        return
    client = POEditorAPI(api_token=api_key)
    languages = client.list_project_languages('162959')
    # pull down translations
    for locale in languages:
        logger.warning('Found translation for {code}: {percent}%'.format(code=locale['code'], percent=locale['percentage']))
        if locale['percentage'] > 0:
            path = os.path.join('shared_web', 'translations', locale['code'].replace('-', '_'), 'LC_MESSAGES')
            if not os.path.exists(path):
                os.makedirs(path)
            pofile = os.path.join(path, 'messages.po')
            logger.warning('Saving to {0}'.format(pofile))
            if os.path.exists(pofile):
                os.remove(pofile)
            client.export(project_id='162959', language_code=locale['code'],
                          local_file=pofile, filters=['translated', 'not_fuzzy'])

    # Compile .po files into .mo files
    validate_translations.ad_hoc()
    compiler = compile_catalog()
    compiler.directory = os.path.join('shared_web', 'translations')
    compiler.domain = ['messages']
    compiler.run()
    # hack for English - We need an empty folder so that Enlish shows up in the 'Known Languages' list.
    path = os.path.join('shared_web', 'translations', 'en', 'LC_MESSAGES')
    if not os.path.exists(path):
        os.makedirs(path)
Exemple #3
0
def run():
    api_key = configuration.get("poeditor_api_key")
    if api_key is None:
        print("Missing poeditor.com API key")
        return
    client = POEditorAPI(api_token=api_key)
    languages = client.list_project_languages("162959")
    # pull down translations
    for locale in languages:
        print("Found translation for {code}: {percent}%".format(code=locale['code'], percent=locale['percentage']))
        if locale['percentage'] > 0:
            path = os.path.join('decksite', 'translations', locale['code'].replace('-', '_'), 'LC_MESSAGES')
            if not os.path.exists(path):
                os.makedirs(path)
            pofile = os.path.join(path, 'messages.po')
            print('Saving to {0}'.format(pofile))
            if os.path.exists(pofile):
                os.remove(pofile)
            client.export("162959", locale['code'], local_file=pofile)
    # Compile .po files into .mo files
    compiler = compile_catalog()
    compiler.directory = os.path.join('decksite', 'translations')
    compiler.domain = ['messages']
    compiler.run()
    # hack for English - We need an empty folder so that Enlish shows up in the 'Known Languages' list.
    path = os.path.join('decksite', 'translations', 'en', 'LC_MESSAGES')
    if not os.path.exists(path):
        os.makedirs(path)
Exemple #4
0
 def run(self):
     compiler = babel.compile_catalog(self.distribution)
     option_dict = self.distribution.get_option_dict('compile_catalog')
     compiler.domain = [option_dict['domain'][1]]
     compiler.directory = option_dict['directory'][1]
     compiler.run()
     super().run()
Exemple #5
0
 def run(self):
     compiler = babel.compile_catalog(self.distribution)
     option_dict = self.distribution.get_option_dict('compile_catalog')
     compiler.domain = [option_dict['domain'][1]]
     compiler.directory = option_dict['directory'][1]
     compiler.run()
     super().run()
Exemple #6
0
 def run(self):
     from babel.messages.frontend import compile_catalog
     compiler = compile_catalog(self.distribution)
     option_dict = self.distribution.get_option_dict('compile_catalog')
     compiler.domain = [option_dict['domain'][1]]
     compiler.directory = option_dict['directory'][1]
     compiler.run()
     super().run()
Exemple #7
0
    def run(self):
        from babel.messages.frontend import compile_catalog

        compiler = compile_catalog(self.distribution)
        compiler.domain = ["ancap_bot"]
        compiler.directory = "ancap_bot/locale"
        compiler.run()
        super().run()
Exemple #8
0
 def run(self):
     from babel.messages.frontend import compile_catalog
     po_compiler = compile_catalog(self.distribution)
     po_compiler.initialize_options()
     po_compiler.domain = domain
     po_compiler.directory = locale_dir
     po_compiler.finalize_options()
     po_compiler.run()
     install.run(self)
Exemple #9
0
 def run(self):
     from babel.messages.frontend import compile_catalog
     po_compiler = compile_catalog(self.distribution)
     po_compiler.initialize_options()
     po_compiler.domain = domain
     po_compiler.directory = locale_dir
     po_compiler.finalize_options()
     po_compiler.run()
     install.run(self)
Exemple #10
0
    def setUp(self):
        self.olddir = os.getcwd()
        self.datadir = os.path.join(os.path.dirname(__file__), "data")
        os.chdir(self.datadir)
        _global_log.threshold = 5  # shut up distutils logging

        self.dist = Distribution(dict(name="TestProject", version="0.1", packages=["project"]))
        self.cmd = frontend.compile_catalog(self.dist)
        self.cmd.initialize_options()
Exemple #11
0
def run_compile_catalog(setuptools_command):
    from babel.messages.frontend import compile_catalog

    compiler = compile_catalog(setuptools_command.distribution)
    option_dict = setuptools_command.distribution.get_option_dict("compile_catalog")
    compiler.domain = [option_dict["domain"][1]]
    compiler.directory = option_dict["directory"][1]
    compiler.use_fuzzy = option_dict["use_fuzzy"][1]
    compiler.run()
Exemple #12
0
    def run(self):
        from babel.messages.frontend import compile_catalog

        compiler = compile_catalog(self.distribution)
        option_dict = self.distribution.get_option_dict("compile_catalog")
        compiler.domain = option_dict["domain"][1:]
        compiler.directory = option_dict["directory"][1]
        compiler.run()
        super().run()
Exemple #13
0
 def run(self):
     # https://stackoverflow.com/a/41120180
     from babel.messages.frontend import compile_catalog  # noqa
     compiler = compile_catalog(self.distribution)
     option_dict = self.distribution.get_option_dict("compile_catalog")
     compiler.domain = [option_dict["domain"][1]]
     compiler.directory = option_dict["directory"][1]
     compiler.run()
     super().run()
Exemple #14
0
    def setUp(self):
        self.olddir = os.getcwd()
        os.chdir(data_dir)
        _global_log.threshold = 5  # shut up distutils logging

        self.dist = Distribution(
            dict(name='TestProject', version='0.1', packages=['project']))
        self.cmd = frontend.compile_catalog(self.dist)
        self.cmd.initialize_options()
Exemple #15
0
def compile_languages(cmd):
    """
    Compile all language files
    Needed to generate binary distro
    """
    from babel.messages import frontend

    compile_cmd = frontend.compile_catalog(cmd.distribution)
    cmd.distribution._set_command_options(compile_cmd)
    compile_cmd.finalize_options()
    compile_cmd.run()
Exemple #16
0
def compile_languages(cmd):
    """
    Compile all language files
    Needed to generate binary distro
    """
    from babel.messages import frontend

    compile_cmd = frontend.compile_catalog(cmd.distribution)
    cmd.distribution._set_command_options(compile_cmd)
    compile_cmd.finalize_options()
    compile_cmd.run()
Exemple #17
0
 def run(self):
     for locale in self.locales:
         compiler = compile_catalog(self.distribution)
         compiler.initialize_options()
         compiler.domain = self.domain
         compiler.directory = self.directory
         compiler.locale = locale
         compiler.use_fuzzy = self.use_fuzzy
         compiler.statistics = self.statistics
         compiler.finalize_options()
         compiler.run()
 def run(self):
     for language in settings.TRANSLATIONS:
         for domain, default_lang in settings.TRANSLATION_DOMAINS.items():
             if language == default_lang:
                 continue  # Default language of the domain doesn't need translations
             print('Compiling po file for {language} in domain {domain}'.
                   format(language=language, domain=domain))
             compiler = babel_frontend.compile_catalog()
             _setup_babel_command(compiler, domain, language,
                                  _po_path(language, domain))
             _run_babel_command(compiler)
Exemple #19
0
 def run(self):
     from babel.messages.frontend import compile_catalog
     for locale in self.locales:
         compiler = compile_catalog(self.distribution)
         compiler.initialize_options()
         compiler.domain = self.domain
         compiler.directory = self.directory
         compiler.locale = locale
         compiler.use_fuzzy = self.use_fuzzy
         compiler.statistics = self.statistics
         compiler.finalize_options()
         compiler.run()
Exemple #20
0
    def setUp(self):
        self.olddir = os.getcwd()
        os.chdir(data_dir)
        _global_log.threshold = 5  # shut up distutils logging

        self.dist = Distribution(dict(
            name='TestProject',
            version='0.1',
            packages=['project']
        ))
        self.cmd = frontend.compile_catalog(self.dist)
        self.cmd.initialize_options()
Exemple #21
0
 def run(self):
     from babel.messages.frontend import compile_catalog
     compiler = compile_catalog()
     option_dict = self.distribution.get_option_dict('compile_catalog')
     if option_dict.get('domain'):
         compiler.domain = [option_dict['domain'][1]]
     else:
         compiler.domain = ['messages']
     compiler.use_fuzzy = True
     compiler.directory = option_dict['directory'][1]
     compiler.run()
     super().run()
Exemple #22
0
def compile(translate_dir, locale, domain="messages"):
    from distutils.errors import DistutilsOptionError
    from babel.messages.frontend import compile_catalog
    cmdinst = compile_catalog()
    cmdinst.initialize_options()
    cmdinst.directory = translate_dir
    cmdinst.locale = locale
    cmdinst.domain = domain
    try:
        cmdinst.ensure_finalized()
        cmdinst.run()
    except DistutilsOptionError as err:
        raise err
Exemple #23
0
 def run(self):
     try:
         from babel.messages.frontend import compile_catalog
         compiler = compile_catalog(self.distribution)
         option_dict = self.distribution.get_option_dict('compile_catalog')
         compiler.domain = [option_dict['domain'][1]]
         compiler.directory = option_dict['directory'][1]
         compiler.run()
     except Exception as e:
         print ("Error compiling message catalogs: {}".format(e),
             file=sys.stderr)
         print ("Do you have Babel (python-babel) installed?",
             file=sys.stderr)
     #super(InstallWithCompile, self).run()
     install.run(self)
Exemple #24
0
def init(seed, sync):
    echo('Creating database...')
    db.create_all()
    echo(f'Updating node... (seed: {seed})')
    if sync:
        Node.update(Node.get(url=seed))
        echo('Syncing blocks...')
        Block.sync(echo=echo)

    echo('Compiling translations...')
    dir_path = os.path.abspath(os.path.dirname(__file__))
    compile_command = compile_catalog()
    compile_command.directory = dir_path + '/translations'
    compile_command.finalize_options()
    compile_command.run()
Exemple #25
0
 def run(self):
     try:
         from babel.messages.frontend import compile_catalog
         compiler = compile_catalog(self.distribution)
         option_dict = self.distribution.get_option_dict('compile_catalog')
         compiler.domain = [option_dict['domain'][1]]
         compiler.directory = option_dict['directory'][1]
         compiler.run()
     except Exception as e:
         print("Error compiling message catalogs: {}".format(e),
               file=sys.stderr)
         print("Do you have Babel (python-babel) installed?",
               file=sys.stderr)
     #super(InstallWithCompile, self).run()
     install.run(self)
Exemple #26
0
    def run(self):
        # prepare messages.po
        merge_po_files()

        # compile translation
        from babel.messages import frontend as babel
        distribution = copy.copy(self.distribution)
        cmd = babel.compile_catalog(distribution)
        cmd.directory = os.path.join(os.path.dirname(__file__), "foris",
                                     "locale")
        cmd.domain = "messages"
        cmd.ensure_finalized()
        cmd.run()

        # run original build cmd
        build_py.run(self)
def upload_translation():
    if 'file' not in request.files:
        return 'No file part'
    file = request.files['file']
    if file.filename == '':
        return 'No selected file'
    extension = os.path.splitext(file.filename)[1]
    if file and extension == '.po':
        try:
            l_code = request.form["l_code"]
            file_destination = BASE_TRANSLATIONS_DIR + "/" + l_code + "/LC_MESSAGES"
            file.save(os.path.join(file_destination, "messages.po"))
            compiler = babel.compile_catalog()
            compiler.input_file = os.path.join(file_destination, "messages.po")
            compiler.output_file = os.path.join(file_destination, "messages.mo")
            compiler.run()
            return "Uploading and Compiling Done!"
        except Exception, e:
            return str(e)
Exemple #28
0
 def upload_translation(self):
     if 'file' not in request.files:
         return 'No file part'
     file = request.files['file']
     if file.filename == '':
         return 'No selected file'
     extension = os.path.splitext(file.filename)[1]
     if file and extension == '.po':
         try:
             l_code = request.form["l_code"]
             file_destination = BASE_TRANSLATIONS_DIR + "/" + l_code + "/LC_MESSAGES"
             file.save(os.path.join(file_destination, "messages.po"))
             compiler = babel.compile_catalog()
             compiler.input_file = os.path.join(file_destination, "messages.po")
             compiler.output_file = os.path.join(file_destination, "messages.mo")
             compiler.run()
             return "Uploading and Compiling Done!"
         except Exception, e:
             return str(e)
Exemple #29
0
    def build_i18n(self):
        """
        Compiling files for gettext from *.po to *.mo with the proper target path
        """
        info('compiling i18n files')
        from babel.messages.frontend import compile_catalog
        compiler = compile_catalog(self.distribution)
        compiler.domain = [GETTEXT_DOMAIN]

        for po in glob.glob(os.path.join(GETTEXT_SOURCE, '*.po')):
            lang = os.path.basename(po[:-3])
            mo = os.path.join(self.build_base, GETTEXT_TARGET, lang,
                              'LC_MESSAGES', 'terminator.mo')

            directory = os.path.dirname(mo)
            if not os.path.exists(directory):
                os.makedirs(directory)

            if newer(po, mo):
                compiler.input_file = po
                compiler.output_file = mo
                compiler.run()
Exemple #30
0
 def _compile_languages(self):
     from babel.messages import frontend
     compile_cmd = frontend.compile_catalog(self.distribution)
     self.distribution._set_command_options(compile_cmd)
     compile_cmd.finalize_options()
     compile_cmd.run()
Exemple #31
0
def compile():
    cmd = babel.compile_catalog(dist)
    cmd.directory = 'translations'

    cmd.finalize_options()
    cmd.run()
Exemple #32
0
        updater.output_dir = locale_path
        updater.locale = locale
        updater.omit_header = True
        updater.finalize_options()
        updater.run()
        print('завершено обновление: ' + locale)
    else:
        initializer = init_catalog()
        initializer.initialize_options()
        initializer.domain = domain
        initializer.input_file = pot_file
        initializer.output_dir = locale_path
        initializer.locale = locale
        initializer.finalize_options()
        initializer.run()
        print('завершена инициализация: ' + locale)

# компилируем локали
for locale in locales:
    po_file_path = os.path.join('.', locale_path, locale, 'LC_MESSAGES',
                                domain + '.po')
    compiler = compile_catalog()
    compiler.initialize_options()
    compiler.locale = locale
    compiler.domain = domain
    compiler.directory = locale_path
    compiler.input_file = po_file_path
    compiler.use_fuzzy = True
    compiler.finalize_options()
    compiler.run()
    print('завершена компиляция: ' + locale)
def compile_catalogs():
    cmd = compile_catalog()
    cmd.directory = os.path.abspath(
        os.path.join(noggin.__path__[0], "translations"))
    cmd.domain = ["messages"]
    cmd.run()
Exemple #34
0
 def _compile_languages(self):
     from babel.messages import frontend
     compile_cmd = frontend.compile_catalog(self.distribution)
     self.distribution._set_command_options(compile_cmd)
     compile_cmd.finalize_options()
     compile_cmd.run()
Exemple #35
0
 def run(self):
     babel_cc = babel.compile_catalog(self.distribution)
     babel_cc.domain = ["rc_profit_calc"]
     babel_cc.directory = "./locale"
     babel_cc.run()
     super().run()
Exemple #36
0
    def __init__(self, dist, **kw):
        from babel.messages import frontend as babel

        self.babel_compile_messages = babel.compile_catalog(dist)
        Command.__init__(self, dist, **kw)
Exemple #37
0
 def __init__(self, dist, **kw):
     from babel.messages import frontend as babel
     self.babel_compile_messages = babel.compile_catalog(dist)
     Command.__init__(self, dist, **kw)
Exemple #38
0
def compile():
    cmd = babel.compile_catalog(dist)
    cmd.directory = 'translations'

    cmd.finalize_options()
    cmd.run()