def ad_hoc() -> int: dist = Distribution(dict( name='Penny-Dreadful-Tools' )) dist.message_extractors = { # type: ignore 'decksite': [ ('**.py', 'python', {}), ('**.mustache', extract_mustache, {}) ], 'logsite': [ ('**.py', 'python', {}), ('**.mustache', extract_mustache, {}) ] } compiler = frontend.extract_messages(dist) compiler.initialize_options() compiler.output_file = './shared_web/translations/messages.pot' compiler.input_paths = ['decksite', 'logsite'] compiler.finalize_options() compiler.run() api_key = configuration.get('poeditor_api_key') if api_key is None: return exitcode() client = POEditorAPI(api_token=api_key) client.update_terms('162959', './shared_web/translations/messages.pot') return exitcode()
def pushTerms(config, sync_terms=False): """ Pushes new terms to POEditor """ assert config client = POEditorAPI(api_token=_get_api_token(config)) sections = config.sections() for s in sections: if s.startswith("project."): terms = config.get(s, 'terms') if config.has_option( s, 'terms') else None if terms: project_id = config.get(s, "project_id") print(" - Project: {0}, {1}\n".format(s, terms)) client.update_terms(project_id, terms, sync_terms=sync_terms) # Avoids API rate limit: https://poeditor.com/docs/error_codes#code-4048 sleep(32)
def ad_hoc(): dist = Distribution(dict(name='Penny-Dreadful-Tools')) dist.message_extractors = { 'decksite': [('**.py', 'python', {}), ('**.mustache', extract_mustache, {})] } compiler = frontend.extract_messages(dist) compiler.initialize_options() compiler.output_file = './decksite/translations/messages.pot' compiler.input_paths = 'decksite' compiler.finalize_options() compiler.run() api_key = configuration.get("poeditor_api_key") if api_key is None: return client = POEditorAPI(api_token=api_key) client.update_terms("162959", './decksite/translations/messages.pot')
def init(config): """ Initializes the project on POEditor based on the configuration file. """ assert config client = POEditorAPI(api_token=_get_api_token(config)) sections = config.sections() for s in sections: if s.startswith("project."): print(" - Project: {}".format(s)) project_id = config.get(s, "project_id") # 1. Push terms terms = config.get(s, 'terms') if config.has_option( s, 'terms') else None if terms: project_id = config.get(s, "project_id") print(" - Terms: {0}".format(terms)) client.update_terms(project_id, terms) # 2. Create/add languages options = config.options(s) for o in options: if o.startswith("trans."): lang = o[6:] try: client.add_language_to_project(project_id, lang) except POEditorException: pass client.update_definitions(project_id=project_id, file_path=config.get(s, o), language_code=lang, overwrite=True) print(" - Language added: {}".format(lang))