[BTS] Mod has only english language

openyourmind

Chieftain
Joined
Feb 22, 2016
Messages
51
Some mods when you go to options, you can change language in them.

For the one I am using (Better Bat AI), only english is available. If I change before launching the mod, text is empty for all the buttons and messages.

How can I make the mod not just english?
 
The vanilla text loading engine is very primitive. Text is stored like this:
PHP:
<TEXT>
       <Tag>TXT_KEY_CITY_NAME_VIENNA</Tag>
       <English>Vienna</English>
       <French>Vienne</French>
       <German>Wien</German>
       <Italian>Vienna</Italian>
       <Spanish>Viena</Spanish>
   </TEXT>
CivilizationIV.ini has a setting called Language, which is an int. It basically tells how many tags to skip meaning English is 0, French is 1 etc. When Language is higher than the number of languages for the TXT_KEY, then the text will be blank, hence empty ingame.

You can solve this in two ways. One is to copy paste English 20 times, making English appear regardless of what the user have set Language to.

The other is to mod CvGameText::read() in CvInfos.cpp. More specifically remove the line
PHP:
for (j = 0; j < iNumLanguages; j++)
This will make the game ignore the Language from the ini and always pick the first one. It's the easiest solution, but it does require you to compile your own DLL file.
 
Thanks a lot for answering. What I want though is basically being able to choose language in a mod.

Compare this (vanilla)
upload_2019-1-24_23-33-23.png

To this (mod)
upload_2019-1-24_23-33-46.png


Why does mod show only english? What is the problem? For example, I want to use French in the mod, all the txt_keys are translated in the mod.
 
I added more details here because this part of the code is fully modable in the DLL and as such this post should be useful to anybody who wants to mod it.

This post applies to vanilla/unmodded behavior only!
This can be rewritten to behave completely different if a mod has a modded DLL.

The language setup

The DLL has a global variable called NUM_LANGUAGES. It can be set with CvGameText::setNumLanguages(int iNum), though vanilla doesn't actually use this function.

The language menu is a python menu (hidden in the exe), which calls CvGameText::getNumLanguages(). This call can be modded both in the function and in the python interface (can point to a different function).

The names of the languages are named TXT_KEY_LANGUAGE_ + index, like TXT_KEY_LANGUAGE_0, TXT_KEY_LANGUAGE_1 etc.

GlobalDefinesALT has MAX_NUM_LANGUAGES. It sets the upper limit for how many languages the menu can handle (vanilla sets this to 100)

How NUM_LANGUAGES is set
It starts at 0.

When CvGameText::read() is called, iNumLanguages is set to NUM_LANGUAGES. If this is 0, it is set to MAX_NUM_LANGUAGES + 1 instead.

When reading a string, it loops iNumLanguages times. If it tries to read more languages than there are present in the xml, it will set NUM_LANGUAGES to match the number of languages present in xml.

Missing languages
When you expect 5 languages, but only see 1, odds are that there is one TXT_KEY somewhere, which only has English. NUM_LANGUAGES will then be set to 1. It doesn't matter how many languages you have in general, only how many you have in the TXT_KEY with the fewest languages.

Sadly the DLL doesn't tell or even store in memory which TXT_KEY is responsible for shortening the list. You have to mod the DLL to tell you or look through your text xml files.
 
Thank you very much for your helpful explanations! I will take a look, even if there are many text files :D
 
In RFC DoC, we had the same problem, because it also uses BUG. The reason is that many texts do not have all languagues defined. For example:

Code:
    <TEXT>
        <Tag>TXT_KEY_BUG_OPT_MAININTERFACE__FIELDOFVIEW_TEXT</Tag>
        <English>Field of View</English>
        <German>Field of View (FOV)</German>
        <Italian>Campo visuale</Italian>
    </TEXT>

As you can see, it misses the French and Spanish language tag. In RFC DoC, we fixed it by adding all missing language tags to the files. Below is the fixed version (copied the English text to the other languagues).

Code:
    <TEXT>
        <Tag>TXT_KEY_BUG_OPT_MAININTERFACE__FIELDOFVIEW_TEXT</Tag>
        <English>Field of View</English>
        <French>Field of View</French>
        <German>Field of View (FOV)</German>
        <Italian>Campo visuale</Italian>
        <Spanish>Field of View</Spanish>
    </TEXT>

All files with fixed tags can be found in the link below. That folder also has some non-BUG related files or texts in the files, but you can ignore them.
https://github.com/MeuhV1/Dawn-of-Civilization/tree/develop/Assets/XML/Text/External
 
merijn_v1, it seems bug files were already fixed in the mod.

Could you recommend maybe some app that would help in making sure all the tags are in place and in correct order? Right now I am just scrolling through them through notepad++ so I am sure there is a better way than this?
 
Back
Top Bottom