Package: i18n-generator
i18n Generator, a powerful library to easily internationalize projectsWhat is it ?i18n-generatoris a Python package that provides a fast way to internationalize your app, based on your native language.
Translation is done using these technologies depending oflanguage classification:Koreanic :PapagoChinese :IflytekJaponic :IcibaLatin :BingGerman :BingCyrillic :Google TranslateFor the rarest languages and by default if one service is not available :Google TranslateWhere to get it ?The source code is currently hosted on GitHub at:https://github.com/LPauzies/i18n-generatorBinary installers for the latest released version are available at thePython Package Index (PyPI).pipinstalli18n-generatorHow to use iti18n-generator generates the translation from a native language to a list of other languages. To use it, you will need amain.jsonfile that is containing a json documentCommand lineHelppython-mi18ngenerator-hVersionpython-mi18ngenerator-vUsing configuration filepython-mi18ngenerator--configconfig.yamlWithconfig.yaml:main-file:~/main.json# Path to main filefrom-language:fr# Should always be a short localeto-language:# Should be a list of short locale-en-zh-ru-ptYou can find the list of i18n localeshere. For France for example, the short locale would be "fr". For China, the short locale would be "zh".Using CLI arguments# Example of use with CLI argumentspython-mi18ngenerator--main-filemain.json--from-languagefr--to-languagees,zh,enWithmain.jsonas main json file containing values to translate from french (fr) to spanish, chinese and english (es,zh,en)Python packageFrom JSON filefromi18ngenerator.i18ngeneratorimportI18nGeneratorfromi18ngenerator.languagesimportLanguageimportpathlib# Using json filejson_file=pathlib.Path("path/to/main.json")from_language=Language.ENGLISHto_language=[Language.FRENCH,Language.CHINESE]i18n_generator=I18nGenerator()i18n_generator.generate_translation_from_json(json_file,from_language,to_language)From Python dictfromi18ngenerator.i18ngeneratorimportI18nGeneratorfromi18ngenerator.languagesimportLanguage# Using dict objectjson_dict={"dummy_key_1":"Hello","dummy_key_2":"I am Lucas ! I am 24 years old."}from_language=Language.ENGLISHto_language=Language.FRENCHi18n_generator=I18nGenerator()result=i18n_generator.generate_translation_from_dict(json_dict,from_language,to_language)print(result)>>>{"dummy_key_1":"Bonjour","dummy_key_2":"Je suis Lucas! J'ai 24 ans."}Just for translationfromi18ngenerator.translatorimportTranslatorfromi18ngenerator.languagesimportLanguagetext="Bonjour, je suis Lucas."from_language=Language.FRENCHto_language=Language.ENGLISHtranslated_text=Translator.translate_text(text,from_language,to_language)print(translated_text)>>>"Hello, I am Lucas."Dependenciestranslators - Translators is a library which aims to bring free, multiple, enjoyable translationnltk - The Natural Language Toolkit (NLTK) is a Python package for natural language processingpyyaml - YAML parser and emitter for PythonBuild from sourcesDownload the sources :herepythonsetup.pyinstallLicenseGPLv3How to contribute ?All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.FAQ & TroubleshootingWhich languages can I use ?You can consider using these lines of code to see which languages are supported by i18n-generatorfromi18ngenerator.languagesimportLanguageprint(list(Language))>>>[<Language.ENGLISH:'en'>,<Language.CHINESE:'zh'>,<Language.FRENCH:'fr'>,...]Why is it sometimes slow to generate my translated files ?This package is based ontranslatorswhich is a free package and free to use. It is using Google translate API to make translation and sometimes, it is not instantly generated. The algorithm providing the translation then need to wait a bit for the translation.