New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add i18n support #49
Comments
In terms of development, all strings must be marked with gettext() around them. And the #include <../i18n/libintl.h> must be included at the top of every file that uses that. Two new dlls will need to be distributed with the .exe: iconv.dll and intl.dll. Maybe it's possible to statically link (I think that's the term) the source from gettext right into the exe which would just make the exe grow a little. Not sure - that would probably be a follow-on. After all strings are marked with gettext, one would run xgettext on the code to generate a messages.po file that would be filled out by a translator. Then, one runs msgfmt to turn that messages.po into a binary messages.mo file and that is included in a new i18n subdirectory of the dsn directory - actually it would be a i18n/**/LC_MESSAGES/ subdirectory where ** is the local identifier like "en" or "fr". |
One problem is that some of the hardcoded strings are in global variables like the MENU_ENTRY StartMenu global variable. This initialization (and now its gettext lookup) happen very early in the initialization of the program - before the config file is loaded. So, at least for an IOC, we will use environment variables or parameters to start the .exe with localization settings. |
Another option that would not require "compilation" of po files might be https://github.com/garbageslam/spirit-po While this is non-standard and it doesn't seem to be active, this would allow people to change translation without running any external programs. Speed of execution is not too much of a concern here anyway since we are talking about turn-based games. |
The spirit-po project was very attractive, but it relied on including spirit boost which looked to me to be a HUGE library that I would have had to include in the project which was just not something that I think we wanted to do. |
This SO question provides a good overview and is left with gettext: https://stackoverflow.com/questions/2185568/alternatives-to-gettext |
I dug into trying to use https://github.com/kahrl/gettext-msvc/ to create statically linked libs of libintl and libiconv and I was able to compile them but ended up with unintelligible (to me) linker errors, which stopped me in my tracks:
|
Continue to get linking errors when trying this build as well: https://osdn.net/projects/libintl-msvc10/downloads/63654/libintl-msvc10-0.2.2-gettext-0.19.5.1base.zip/ I am giving up on statically linking at this point. |
Initial attempt at a roll-your-own solution using JSON is commit df099d7 |
The developer suggests using the "messageMap.txt" file in the game "Data" folder to make translations by inserting original and translated strings into it according to a certain scheme.. This seems to work, but there are encoding problems: When I change the encoding of the file "messageMap.txt", I get an error in the game: Another problem is that the GENERAL GRAPHICS ERROR message displays in game apparently when the game accesses the "messageMap.txt" file: GENERAL GRAPHICS ERROR message displays immediately after the first movement of the mouse cursor and does not disappear until you switch to another menu. If there is no translation, everything is fine, if the text is affected by this file, this message appears again after the movement of the mouse. |
The text displaying incorrectly is because the json reader only reads in UTF-8, and because the file is UTF-8, the Cyrillic characters are coded in Unicode with 2 bytes instead of one. The font doesn't have all the Unicode glyphs pre-rendered and the CDXBitmapFont::Draw* routines are only designed to write 8-bit (1 byte) characters (see #41) right now. I will have to translate backward to ANSI I think. |
Yep, translating back to ANSI with the routine here did the trick: https://stackoverflow.com/questions/8298081/convert-utf-8-to-ansi-in-c/35272822#35272822 |
Huge THANKS! Now everything seems to be working fine! Working on interface translation ... |
Considering that the work may take some more time, In case someone needs to test its functionality now, I will post the current version of the "messageMap.txt" here: messageMap.txt. Except for in-game items and spells, the work is about 70-90% done (while I may be wrong and underestimate the scale of the game ...) |
Here is the new file messageMap.txt: Some nuances:
|
Here is a new file with new strings and markups added to find an opportunity to translate the unsuitable strings. For now, I will gradually add items, spells, etc. to the file. |
Here is the new version of the "messageMap.txt" file. messageMap.txt_008 (all items translated).zip Added and translated all in-game items (at least those that were in my "items.txt" file), as well as several new strings that I discovered during the game. Then I will translate spells, monsters, etc. |
New messageMap.txt here: messageMap.txt_012 (all items and spells translated).zip The names of all in-game spells have been translated, as well as new lines and some additional minor adjustments made. Now the translation of the names of the monsters is next... |
When you are all set and we are sure it is able to do all you need, lmk and I will cut a 5.28 release. Since you are the primary stakeholder on this atm! |
So the new file is here! messageMap.txt_013 (all items, spells, monsters translated).zip The names of the game monsters have been translated into Russian. Now I need your help please in order to get to the text that is not possible to get with just this file ... |
Before the release of version 5.28, we need to deal with the translation of the text that I could not translate using the message.txt file |
Problem № 001: It is necessary to provide the ability to translate without affecting the changing numbers. Is it possible to translate this text and how to do it? I cannot enter this text with numbers into the "MessageMap.txt" file, as the numbers will constantly change. You can try to enter strings into the file for each new combination of numbers, but then you get just a huge number of combinations. |
So far, that's all I've noticed. I ask for help, thanks |
Yeah I think just about all of these will require minor code changes. The strings are hardcoded in and appended together before they are passed to the DisplayText methods. I think number 6 might be able to be done by putting /GSTR or some number of spaces after STR but the rest will have to be minor code changes. |
For number 4, check out [TimeText] in specialAbilities.txt |
Number 5 is in Global_Display in specialAbilities.txt |
001, 002, 004, 008, 009, 010 ! SOLVED ! Thank you very much! 003, 005, 006, 007 still can't fix... |
All the rest problems with translation for current moment SOLVED, TY! I need some more time to identify any other similar translation problems... |
Closing. Any other i18n tweaks should be filed under separate tickets. |
Integrate the gnu gettext library to support translation of hardcoded strings into different languages.
Discussion at http://ua.reonis.com/index.php?topic=4052.0
The text was updated successfully, but these errors were encountered: