Translate multi langage word with config files.
日本語版はこちら
Clone this repository with below command.
git clone https://github.com/K0j1-y/translator.git
- Add import part.
Please change path part with your environment.from translator import Translator from lang_type import LangType
- Initialize Translator class.
If you need, please change arguments.
Translation file direcotry, a part of file name, default language.self._tr = Translator()
- Add translation part
Argment is json file's keyword.
print(self._tr.tr("00-000"))
Run this code in your script.
Arguments is language type from LangType.
self._tr.change_lang(LangType.JP)
Config file stored src/lib directory.
The config file consists of a common part and a language name part.
The default is "translation" and "EN".
The config file structure is below.
{
"keyword": "translation word",
...
}
The keyword type is str and user must set same word in all languages.
-
Create a file named
translation_[unique string].json
in the same directory as the other translation json files.
That file structure is same as other traslation file. and same keywords. -
Add language type in src/lang_type.py.