Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,324
There was a request for knowing what goes on with development. We don't have a blog, twitter or anything like that, mainly because we do not have anybody to maintain something like that. We are still recruiting more people, which includes people for any task for the mod itself as well as publicity like building a web site.
For the time being I decided to add this thread to give hints on what is going on regarding development. It's in no way complete and there is way more information available in the git log and the issue system on git. This is just highlights of major events.
To put it mildly: the vanilla translation support sucks big time. It allows switching the language used in the game, but that's about it for the good part. It doesn't store which language you picked, but rather the index of that language. When reading the text from xml, it will read the language at that index. The setting is stored in CivilizationIV.ini (my documents) and it's called Language.
One huge flaw in this system is that if you select language 0, you get language 0 in all mods. This has worked out ok so far because the first 5 languages are set by vanilla, hence the same in all mods. However imagine when we add more languages. We could end up with say Russian as language 6 in one mod and 7 in another mod. Also if we load language 7 in a mod with just 5 languages, all text will vanish.
Another flaw is that adding a new string (TXT_KEY) requires adding it in all languages and the person adding new text usually doesn't speak all the languages well enough to do the translation work as well as programming. This has resulted in adding English text in non-English languages just because the game requires something to be added.
With the talk of adding Brazilian Portuguese (and now apparently Russian too), I started working on a complete rewrite of how translations work.
What I have done
Since most of the code is hidden inside the exe file (can't get modded), the languages still need to be stored as a number in CivilizationIV.ini. The problem is not the number itself, but rather the issue that all mods needs to agree on which language to use for each number. I added a table for this and added an additional 20 languages to it (to a total of 25). If all mods agree on using this table, the selected language will be kept even when switching mod.
Getting a list of 25 translations is no good, particularly if there is only 2-3 real translations. I added a new xml file, which tells which languages to add to the language menu. This means it's perfectly fine to use language 0, 2, 17 only and they will show up as 3 languages. This allows mods to agree on which language is used for each number while maintaining the ability to not have the same list ingame. One mod can add a new translation while another mod doesn't. It also allows translations to appear at whatever order the xml modder wants regardless of the numbers for the languages.
If a translation is missing for a certain TXT_KEY or even missing entirely in the mod, English will be used. This avoids the issue of partial or missing translations results in missing text and it also removes the need to add translations for all languages when adding a new TXT_KEY. This makes it much easier to both add new TXT_KEYs and work on or use partial translations.
Translations for a TXT_KEY can appear in any order as they are located by tag name rather than index. This means it's possible to add English, German and nothing else. Vanilla wants the second language to be French, but now French is missing (not translated) and people using the French translation will get the English "translation". Vanilla's reaction to a TXT_KEY with just English and German is to read German as French due to only using indexes, not tag names.
An interesting twist to using tag names is it's possible to use the "language" Tag. This will make the text ingame appear as the TXT_KEYs. Often useless, but if you spot say a typo ingame, you can switch and get which key you should look up in the text xml files.
Anybody interested in the code can read it here: https://github.com/We-the-People-civ4col-mod/Mod/commit/560a80b37e9305408f1dd3d44c265975d29ae54a
It should be noted that it should be possible to copy it to other mods without issues as it doesn't rely on any mod specific code. In fact it doesn't rely on Colonization specific code, meaning it should work in BTS too.
For the time being I decided to add this thread to give hints on what is going on regarding development. It's in no way complete and there is way more information available in the git log and the issue system on git. This is just highlights of major events.
First entry: translation support
To put it mildly: the vanilla translation support sucks big time. It allows switching the language used in the game, but that's about it for the good part. It doesn't store which language you picked, but rather the index of that language. When reading the text from xml, it will read the language at that index. The setting is stored in CivilizationIV.ini (my documents) and it's called Language.
One huge flaw in this system is that if you select language 0, you get language 0 in all mods. This has worked out ok so far because the first 5 languages are set by vanilla, hence the same in all mods. However imagine when we add more languages. We could end up with say Russian as language 6 in one mod and 7 in another mod. Also if we load language 7 in a mod with just 5 languages, all text will vanish.
Another flaw is that adding a new string (TXT_KEY) requires adding it in all languages and the person adding new text usually doesn't speak all the languages well enough to do the translation work as well as programming. This has resulted in adding English text in non-English languages just because the game requires something to be added.
With the talk of adding Brazilian Portuguese (and now apparently Russian too), I started working on a complete rewrite of how translations work.
What I have done
Since most of the code is hidden inside the exe file (can't get modded), the languages still need to be stored as a number in CivilizationIV.ini. The problem is not the number itself, but rather the issue that all mods needs to agree on which language to use for each number. I added a table for this and added an additional 20 languages to it (to a total of 25). If all mods agree on using this table, the selected language will be kept even when switching mod.
Getting a list of 25 translations is no good, particularly if there is only 2-3 real translations. I added a new xml file, which tells which languages to add to the language menu. This means it's perfectly fine to use language 0, 2, 17 only and they will show up as 3 languages. This allows mods to agree on which language is used for each number while maintaining the ability to not have the same list ingame. One mod can add a new translation while another mod doesn't. It also allows translations to appear at whatever order the xml modder wants regardless of the numbers for the languages.
If a translation is missing for a certain TXT_KEY or even missing entirely in the mod, English will be used. This avoids the issue of partial or missing translations results in missing text and it also removes the need to add translations for all languages when adding a new TXT_KEY. This makes it much easier to both add new TXT_KEYs and work on or use partial translations.
Translations for a TXT_KEY can appear in any order as they are located by tag name rather than index. This means it's possible to add English, German and nothing else. Vanilla wants the second language to be French, but now French is missing (not translated) and people using the French translation will get the English "translation". Vanilla's reaction to a TXT_KEY with just English and German is to read German as French due to only using indexes, not tag names.
An interesting twist to using tag names is it's possible to use the "language" Tag. This will make the text ingame appear as the TXT_KEYs. Often useless, but if you spot say a typo ingame, you can switch and get which key you should look up in the text xml files.
Anybody interested in the code can read it here: https://github.com/We-the-People-civ4col-mod/Mod/commit/560a80b37e9305408f1dd3d44c265975d29ae54a
It should be noted that it should be possible to copy it to other mods without issues as it doesn't rely on any mod specific code. In fact it doesn't rely on Colonization specific code, meaning it should work in BTS too.