How to prepare a weidu mod for translation

Discuss BGforge translation system itself, in English
Post Reply
Magus
Site Admin
Posts: 80
Joined: Mon Nov 21, 2016 9:13 am

How to prepare a weidu mod for translation

Post by Magus » Sun Dec 03, 2017 11:10 am

If you want to translate a mod at BGforge, it will require some preparation.

First thing you should note is that once you offload translations to BGforge, you will no longer be able to edit them directly. All new translations will have to be added through web interface. No mix and match.

Second, you will need to use a version controlled hosting for the mod. Github, Bitbucket, any other git (or even mercurial, subversion) hosting will do. Easiest to use is Github.

Once you have that, you can start preparing the mod. That basically boils down to having proper file and directory names and correct encodings. Because Weblate cannot guess those things, you should follow the convention to provide this info.

1. Dedicate a separate directory to translations. It could be "tra", or "language", or anything else. Just don't store other stuff in that directory.
Example:
ascension/tra/english
ascension/tra/french
2. Name language directories per WeiDU infer_charsets convention, using the english version. Not "american", but "english". Not "italiano", but "italian". Example:
ascension/tra/spanish
ascension/tra/polish
3. Move all WeiDU setup strings (components names, etc - everything printed to console during installation) into a separate file. It must be called either "setup.tra" or "install.tra".

4. Ensure that all EE-only strings are stored in files ending with "_ee.tra" or named "ee.tra" AND they are encoded in UTF-8.
ascension/tra/spanish/ee.tra
ascension/tra/spanish/dialog_ee.tra
5. Ensure that all remaning files are using proper encoding, as per WeiDU documentation.
Special note: setup.tra/install tra in Russian must be in cp866, not cp1251.

6. Ensure that all existing translations are actual:
- There are no, say, english strings in french tra files
- There are no outdated strings (when a source language string was updated, but translation was not).
Delete any such strings.

6. Create a bgforge.ini file. It shows where the translation files should be found. The two directives are "tra_dir" (directory with translations) and "src_lang" (source language). Defaults values are "tra" and "english". If your values differ from defaults, you need to specify them in the ini.
Example:
[main]
tra_dir = ascension/tra # if this is just "tra", you don't need to specify it
src_lang = russian # if this is "english", you don't need to specify it
7. In git repo settings, add bgforge-weblate (github) user as a collaborator. Also, add a hook to notify the translation system about new strings. The url is https://tra.bgforge.net.

8. Create a request topic here, specifying mod name and repo url.


-------------------------------

If you don't have existing translations, you're done. Wait for a member of BGforge staff to respond.

-------------------------------

If you do have existing translations, you can also stop here and wait.

Alternatively, you could speed up the process by loading your existing translations into Gettext PO, which is what Weblate uses internally. This is done with BGforge PO tools.

9. Check bgforge.ini:
$ cd Ascension
$ cat bgforge.ini

[main]
tra_dir = ascension/tra
src_lang = english
10. Generate POT (PO file template) from source language:
$ poify
Found directory ascension/tra/english
processing ascension.tra
processing balth.tra
processing balth2.tra
processing ee.tra
processing finbodh.tra
processing finmel01.tra
processing finsarev.tra
processing finsol01.tra
processing imoen25j.tra
processing imoen25p.tra
processing irenic2.tra
processing meliss01.tra
processing player1.tra
processing ppguy02.tra
processing sarev25j.tra
processing setup.tra
processing shawnesepilogues.tra
processing shawnesepilogues_ee.tra
processing solar.tra
Processed directory ascension/tra/english with encoding cp1252, the result is in ascension/tra/po/english.pot
$ resave-po ascension/tra/po/english.pot
11. Create a PO file, load an existing translation into it:
$ cd ascension/tra
$ cp po/english.pot po/russian.po
$ dir2msgstr -s russian -o po/russian.po --ext tra

processing ascension.tra with encoding cp1251
processing balth.tra with encoding cp1251
processing balth2.tra with encoding cp1251
processing ee.tra with encoding utf-8
processing finbodh.tra with encoding cp1251
processing finmel01.tra with encoding cp1251
processing finsarev.tra with encoding cp1251
processing finsol01.tra with encoding cp1251
processing imoen25j.tra with encoding cp1251
processing imoen25p.tra with encoding cp1251
processing irenic2.tra with encoding cp1251
processing meliss01.tra with encoding cp1251
processing player1.tra with encoding cp1251
processing ppguy02.tra with encoding cp1251
processing sarev25j.tra with encoding cp1251
processing setup.tra with encoding cp866
processing shawnesepilogues.tra with encoding cp1251
processing shawnesepilogues_ee.tra with encoding utf-8
processing solar.tra with encoding cp1251
Processed directory russian, the result is in po/russian.po
Repeat for other languages. If you encounter any issues in the process, it's probably because the steps 1-8 were not followed closely. Re-check that. If you still can't find the problem, feel free to file an issue on Github.

This additional process will allow for faster adding of your mod to BGforge translation system. But it's not necessary, you can stop at step 8 if you want.
I do not respond to personal messages or emails about my mods and projects. Use their own forums, linked in their own readmes.
Post Reply