pyui Localization and Translation - pytha-3d-cad/pytha-lua-api GitHub Wiki
The PYTHA software is available in many languages and the Lua api makes it easy for you to translate your plugins as well.
First Steps for Translation
If you are a developer, the most important take-away is the following: All strings that will appear in the user interface and all strings that might need to be translated should be written as
pyloc "This text can be translated!"
or (equivalently)
pyloc("This text can be translated as well!")
So when you create a label in a dialog, you should always write the text as
dialog:create_label(1, pyloc "Label Caption in my primary language")
What happens next?
Whenever PYTHA executes your plugin, it collects all pyloc strings from your source code and creates a translation base file named plugin-name.base.xlf. This file is a translation-interchange file in the widely used XLIFF 2.0 format.
If you want to add a new language for your plugin (say, e.g., Chinese), copy the base file (we suggest that you name the copy according to the target language, e.g. *plugin-name.zh.xlf). And then add translations to that new file. Note that the file name is not important, only the target language specified inside the xliff file is relevant.
Every professional translator should know how to handle xliff files, but if you have to do it yourself, we suggest, you use a tool like Poedit (open source, install offline) or Weblate (free plan available, cloud-based) for the task. Note that many other tools for this task exist and this is not a formal endorsement of any particular software, but just a suggestion based on our own experience of use.
Finally...
If you have placed the translated .xlf file into the plugin-folder, then, as soon as you switch PYTHA to the desired language, your plugin will show the translated texts. Note that only those languages are accessible that PYTHA itself supports.
For experienced programmers:
The PYTHA Lua api uses a hash of the original text as the unit@id in the xliff-translation file. If you adjust the wording of a text in the original language, its hash changes and the existing translations of the original text would disappear. To preserve the translations, use a second parameter:
pyloc("Newly worded text", "Original text")
You can also avoid the hash-calculation altogether, by providing unique integer ids for each translatable text
pyloc("This text can be translated", 12345)