def google_translate(self, code, from_lang, to_lang, args): path = os.path.join(self.locales_directory(), code, 'LC_MESSAGES', 'messages.po') for arg in args: if not 'text_' in arg: continue msg_id = args[arg].strip() if '\r' in msg_id: msg_id = '\n'.join(msg_id.splitlines()) translated = i18n.utils.google_translate( from_lang, to_lang, msg_id) catalog.update(path, msg_id, translated)
def update_catalog(self, code, msg_id, msg_text): path = os.path.join(self.locales_directory(), code, 'LC_MESSAGES', 'messages.po') catalog.update(path, msg_id, msg_text) return 'ok'