Need help with displaying umlauts correctly in AGS Fan translation

Started by Mekabor, Thu 18/05/2023 06:22:55

Previous topic - Next topic

Mekabor

Hello everyone,

I hope this message finds you well.
I am currently working on a fan translation using AGS Translation Editor and I'm facing an issue with displaying umlauts (e.g., ä, ö, ü) correctly in the game.
I have tried various methods but have been unsuccessful so far, and I would greatly appreciate any assistance you can provide.

I have discovered so far that it should be related to the font style, but I'm unsure how to change it as I don't have access to the core data, and I only work with .trs and .tra files. I extract the text for the .trs files from the game.exe.

I have noticed that another user successfully translated a similar game and managed to display umlauts correctly.
I am using the same tools, but I am unable to achieve the same result.
I have reached out to that user, but unfortunately, I haven't received a response yet.

I have compared my .trs file with the other one multiple times, and the difference I noticed is that in the other .trs file, the umlauts are represented differently, such as using an equal sign for "ö" and a dollar sign for "ä," and so on.
It seems that the umlauts have been mapped to these special characters, as mentioned in the manual.
However, I am unsure about how this was achieved.
The suggested programs for this task are AGS Translation Editor and FontEdit.
Unfortunately, I cannot locate the font files, and I'm wondering how this was accomplished because the information does not seem to be present in the other .trs file.
I am unsure if there are additional steps or configurations that I might be missing.

I understand that you are all experienced AGS developers, and I apologize for any inconvenience caused by my question.
I have limited knowledge in this area, and I am struggling to find a solution. I have visited various forums and resources, but I have been unable to find a resolution specific to my situation.

Could you kindly provide guidance or suggestions on this particular problem?
Any insights, tips, or examples would be highly appreciated.
Additionally, if you know of any resources or tutorials that specifically address this issue, I would be grateful for any pointers.

Thank you in advance for your time and assistance. I am eager to learn and improve my understanding of AGS, and your help would be invaluable to me.

Best regards,
Mekabor

Snarky

I think the FontEdit instructions are directed to game creators. When you're making a game, changing the fonts is pretty straightforward.

I'm not 100% certain, but if you're doing a fan translation without coordinating with the game creator, you might be stuck with the fonts the game comes with (unless you go in and really hack the game files), and if those fonts don't have the umlaut characters... you're probably out of luck. I don't know that AGS offers any way to replace fonts as part of a third-party translation.

Mekabor

I understand your point about needing access to the core data in order to change the font.
However, I'm also puzzled by how the other user managed to achieve it without modifying the core data.

When comparing my .trs file with the other user's, I noticed that the only difference was the replacement of umlaut characters, such as using "=" for "ä" and "$" for "ü".
Yet, in the game, the umlauts are displayed correctly.
From my perspective, it seems like the umlauts have been mapped to other characters that are not commonly used. However, what I don't understand is the exact method used to achieve this, because this was accomplished solely with the .trs file, and there is nothing else in there except for the translation. No other file was added or modified.

I've tried various methods and explored different options, but I haven't been able to replicate the same results. It's frustrating because it suggests that there might be a way to accomplish this, but the exact approach remains elusive.

I've reached out to the other user for guidance, but I haven't received a response yet. I'll keep trying to contact them and see if they can provide any insights into how they achieved the correct display of umlauts.

If anyone in the forum has encountered a similar situation or has knowledge about specific techniques or tools that could help in this context, I would greatly appreciate your input. It seems that there's a missing piece of the puzzle that could potentially solve this issue.

Thank you for your time and assistance.

Khris

It looks like the other game's creator already used a modified font where the pixels for the = character were changed to those of an ä.

Is it possible the other user contacted the game's creator and had them update the game with a modified font? Because I don't see how else you would get a = in the translation source to display as ä in game.

If the wfn files from the game are inside the game's .exe or data file as-is, you could use a hex editor to change the font's pixels, but that's a long shot I guess.

Crimson Wizard

AGS supports loading external files for much of the game data. Simply placing new fonts in the game dir will override ones in the game package, if their names match. For example, placing "agsfnt0.wfn" in the game dir will override the font 0, and so forth.

Besides that, compiled ags games may be unpacked and repacked; there are tools made that do that, mostly unofficial ones created in the last 20 years, but also we now have ones in our repository too (we do not distribute them "officially" yet). These tools let you unpack a game into separate files, replace some files, and pack back. That's another option for replacing fonts.



In addition, I might mention that AGS engine 3.6.0 supports Unicode mode, which may be turned on by translation too. This gives an opportunity to create proper unicode translations even to older games that were made in ascii mode.

This is explained in the manual here:
https://adventuregamestudio.github.io/ags-manual/Translations.html#additional-options

So, if you place 3.6.0 engine (with SDL2 dll) in the game dir, compile a translation with the "Encoding=utf-8" hint inside (and if TRS is saved as utf-8), and provide unicode-compatible font, then you may have proper translations in any language even for the games that did not support such feature.

Mekabor

Quote from: Khris on Thu 18/05/2023 14:57:58Is it possible the other user contacted the game's creator and had them update the game with a modified font? Because I don't see how else you would get a = in the translation source to display as ä in game.

No, I am 100% certain that the other user did not contact the game developer. The game was not updated or modified in any way. The only thing that was done was converting the .trs file into a .tra file and then changing the game language in the winsetup.exe. That's what surprises me, and I just don't understand how it was done.

Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06AGS supports loading external files for much of the game data. Simply placing new fonts in the game dir will override ones in the game package, if their names match. For example, placing "agsfnt0.wfn" in the game dir will override the font 0, and so forth.

I have tried that. I converted a .ttf file (which includes special characters) into a .wfn file, located the entries for .wfn in the game.exe, renamed the new .wfn files accordingly, and copied them into the game folder. The game loads, but the font in the game doesn't change significantly, and the special characters still aren't displayed.

Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06Besides that, compiled ags games may be unpacked and repacked; there are tools made that do that, mostly unofficial ones created in the last 20 years, but also we now have ones in our repository too (we do not distribute them "officially" yet). These tools let you unpack a game into separate files, replace some files, and pack back. That's another option for replacing fonts.

Such a solution would be convenient, but it doesn't explain how the other user managed to display umlauts correctly in the game using only the .trs file. No other changes were made to the game. Regarding your suggestion of unpacking and repacking game files, it would require transferring all the newly packed data to another computer to run it there, which was not the case in this situation.

Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06In addition, I might mention that AGS engine 3.6.0 supports Unicode mode, which may be turned on by translation too. This gives an opportunity to create proper unicode translations even to older games that were made in ascii mode.

This is explained in the manual here:
https://adventuregamestudio.github.io/ags-manual/Translations.html#additional-options

So, if you place 3.6.0 engine (with SDL2 dll) in the game dir, compile a translation with the "Encoding=utf-8" hint inside (and if TRS is saved as utf-8), and provide unicode-compatible font, then you may have proper translations in any language even for the games that did not support such feature.

I'm not entirely sure if I understand correctly, but are you referring about the "Translation" option under the "Explore Project" tab?
If so, please note that I haven't loaded the game in AGS because it is encrypted.
If I follow the Manual, such as adding "//#encoding=UTF-8" at the top of the .trs file, the Translation is completely ignored.
The .trs file is in UTF-8 encoded, but the .tra file is currently in ANSI, when I convert the .tra file to UTF-8, the Translation is not recognized. As for the last part about "placing 3.6.0 engine (with SDL2 dll) in the game dir," am I understanding correctly that I should copy the entire AGS into the game directory? Would that work even if the data is encrypted?

Crimson Wizard

Quote from: Mekabor on Fri 19/05/2023 02:45:42I have tried that. I converted a .ttf file (which includes special characters) into a .wfn file, located the entries for .wfn in the game.exe, renamed the new .wfn files accordingly, and copied them into the game folder. The game loads, but the font in the game doesn't change significantly, and the special characters still aren't displayed.

A side note, but if I recall correctly, you dont have to convert ttf->wfn, as AGS would try to find ttf first.

Could you please clarify what does "the font in the game doesn't change significantly" means? To make it certain, can you confirm that the new font is being used at all?

Regarding the issue, I don't know if you are aware of this, so must mention: in AGS all games made before 3.6.0 were made in ASCII/ANSI text format. This means that in order to display "extended" characters both the translation text and the font should comply to the same ANSI codepage. It does not really matter which one, what matters is that the ANSI codepage you are saving TRS with must match with the codepage the font is complying to. For this reason people were making "AGS compatible" fonts, if they needed to feature e.g. extended Latin with umlaut, Cyrillic alphabet, and so on. These fonts have to have the letters in particular slots, in accordance to the chosen codepage. For example, see how the letter table looks like in this wikipedia article: https://en.wikipedia.org/wiki/Windows-1252
The problem with this approach also is that when you save TRS in ANSI, the result will depend on your default system codepage. (This setting is also called "Language for non-Unicode applications" in Windows) So this is something to pay attention to.

This is irrelevant if you are going the alternate route, using a Unicode mode.



Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06I'm not entirely sure if I understand correctly, but are you referring about the "Translation" option under the "Explore Project" tab?
If so, please note that I haven't loaded the game in AGS because it is encrypted.

No, I'm referring to the text TRS file, and compiling it with the translation compiler. You should not be needed to launch an Editor for this.

Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06If I follow the Manual, such as adding "//#encoding=UTF-8" at the top of the .trs file, the Translation is completely ignored.
The .trs file is in UTF-8 encoded, but the .tra file is currently in ANSI, when I convert the .tra file to UTF-8, the Translation is not recognized.

Right, I forgot to mention that old translation compilers dont support this. You have to use either one that already supports 3.6.0 feature (I dont know if there's one already), or use our own:
https://www.dropbox.com/s/42widlilgfa2aoq/trac%20--%20ags%20translation%20compiler.zip?dl=0
this tool should be run from command line though.

Note that the Encoding option wont work with the old game or engine exe anyway. (unless it's a 3.6.0 game)


Quote from: Crimson Wizard on Thu 18/05/2023 16:23:06As for the last part about "placing 3.6.0 engine (with SDL2 dll) in the game dir," am I understanding correctly that I should copy the entire AGS into the game directory? Would that work even if the data is encrypted?

No, not the entire AGS, but the engine runtime, called "acwin.exe" for Windows. The standalone engine exe can load games just fine, if it finds them in current location.

Mekabor

Quote from: Crimson Wizard on Fri 19/05/2023 04:14:06A side note, but if I recall correctly, you dont have to convert ttf->wfn, as AGS would try to find ttf first.

Could you please clarify what does "the font in the game doesn't change significantly" means? To make it certain, can you confirm that the new font is being used at all?

I have experimented again and managed to make the game use the other font and therefore display the special characters. However, now the font appears very distorted. Could this have something to do with the font size? How can I change it to make it look better?

With "the font in the game doesn't change significantly," I meant that the font in the game didn't change.

Quote from: Crimson Wizard on Fri 19/05/2023 04:14:06No, I'm referring to the text TRS file, and compiling it with the translation compiler. You should not be needed to launch an Editor for this.

Right, I forgot to mention that old translation compilers dont support this. You have to use either one that already supports 3.6.0 feature (I dont know if there's one already), or use our own:
https://www.dropbox.com/s/42widlilgfa2aoq/trac%20--%20ags%20translation%20compiler.zip?dl=0
this tool should be run from command line though.

I have been using the software AGS_TranslationEditor so far to compile the .trs to .tra.
I tried the program you suggested, is there any manual or instruction available for it?
The game was released in 2006, and I'm not sure if that's considered old yet.

Quote from: Crimson Wizard on Fri 19/05/2023 04:14:06No, not the entire AGS, but the engine runtime, called "acwin.exe" for Windows. The standalone engine exe can load games just fine, if it finds them in current location.

I tried that, and the game starts without any issues. However, when I connect the .trs with the acwin.exe, toget the .tra file, I get an error message, and the game no longer starts with acwin.


Thank you very much for your help. Your suggestion to replace the fonts has been very helpful. If I could now manage to make the letters look nice and readable, I would be satisfied. Although the question of how the other person managed to achieve it with just a .trs file still bothers me a bit.

Crimson Wizard

Quote from: Mekabor on Fri 19/05/2023 06:17:32I have experimented again and managed to make the game use the other font and therefore display the special characters. However, now the font appears very distorted. Could this have something to do with the font size? How can I change it to make it look better?

This is an annoying gap in translation system, but I don't think you can set the font size with TRS.
This may be a proper feature request for the future engine versions.
I think you could maybe try converting ttf->wfn and choose the destination size when you convert (if converter allows this).
Other than that, look for other fonts, or even draw some yourself. There are WFN font editors around, for example this one: https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/editor-plugin-wfn-fonteditor/


Quote from: Mekabor on Fri 19/05/2023 06:17:32I tried that, and the game starts without any issues. However, when I connect the .trs with the acwin.exe, toget the .tra file, I get an error message, and the game no longer starts with acwin.

There's some misunderstanding. You don't use acwin.exe to get tra file from trs, acwin.exe only runs the game.
You need to use the translation compiler to make tra from trs.

Quote from: Mekabor on Fri 19/05/2023 06:17:32I tried the program you suggested, is there any manual or instruction available for it?

You run it from command line. You can run "trac.exe --help" to see the list of options.
The common use is "trac.exe lang.trs lang.tra" -- this will take lang.trs file and create lang.tra.


Quote from: Mekabor on Fri 19/05/2023 06:17:32Although the question of how the other person managed to achieve it with just a .trs file still bothers me a bit.

I might have missed this in your other replies, did that other person translate same game or another game? It's difficult to answer such question without knowing details, or better having the game with translation for analysis.

Mekabor

Quote from: Crimson Wizard on Fri 19/05/2023 06:38:01This is an annoying gap in translation system, but I don't think you can set the font size with TRS.
This may be a proper feature request for the future engine versions.
I think you could maybe try converting ttf->wfn and choose the destination size when you convert (if converter allows this).
Other than that, look for other fonts, or even draw some yourself. There are WFN font editors around, for example this one: https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/editor-plugin-wfn-fonteditor/

If it were possible to adjust the font size through the .trs file, that would be really great.
I did it! I just had to find the right .ttf font, one where the text was small enough to be displayed well.
Thank you for the link. I also found another program called FontForge, which seems to be able to edit and resize fonts. I haven't tried it yet, but you can download it from here: https://fontforge.org/en-US/downloads/windows-dl/

Quote from: Crimson Wizard on Fri 19/05/2023 06:38:01There's some misunderstanding. You don't use acwin.exe to get tra file from trs, acwin.exe only runs the game.
You need to use the translation compiler to make tra from trs.

When I start the game with acwin, it doesn't load the translation, and the game remains in its original language. That's why I thought I needed to create the .tra file from it, my fault.

Quote from: Crimson Wizard on Fri 19/05/2023 06:38:01I might have missed this in your other replies, did that other person translate same game or another game? It's difficult to answer such question without knowing details, or better having the game with translation for analysis.

No problem, it was indeed a lot of text. No, the other person used a different game from the same publisher, but both games were released in the same year, so there shouldn't be too much difference, right?

Yes, I understand that the question is difficult to answer. But, I cannot distribute the game data as it is a commercial game, and I don't want to cause any harm.
Perhaps I should just conclude the question because I have essentially achieved what I wanted.
Now I can finally translate the games and present them to a non-English speaking audience so that they can finally experience how great these games are.
Thank you very much for your help.
Should I summarize the steps to solve my problem again in case someone else encounters a similar issue?

Crimson Wizard

Quote from: Mekabor on Fri 19/05/2023 07:26:55No problem, it was indeed a lot of text. No, the other person used a different game from the same publisher, but both games were released in the same year, so there shouldn't be too much difference, right?

If the other game used different font that contains proper letters with umlauts, that could explain the difference in result.

Then again, the issue may be in a codepage you are saving your TRS, maybe it's not matching the game's font.

Quote from: Mekabor on Fri 19/05/2023 07:26:55Yes, I understand that the question is difficult to answer. But, I cannot distribute the game data as it is a commercial game, and I don't want to cause any harm.

You could perhaps give a link or at least name the game's title. But I guess it's not important anymore if you found the working solution.

Mekabor

Quote from: Crimson Wizard on Fri 19/05/2023 07:45:58If the other game used different font that contains proper letters with umlauts, that could explain the difference in result.

Then again, the issue may be in a codepage you are saving your TRS, maybe it's not matching the game's font.

I still have the feeling that the mapping of the fonts has been changed because in the .trs file, the umlauts are written as special characters, for example, "ä" is represented as "$" but in the game it is displayed as an umlaut. I'm just wondering how this can be achieved with just a .trs file without making any changes to the game files.

Quote from: Crimson Wizard on Fri 19/05/2023 07:45:58You could perhaps give a link or at least name the game's title. But I guess it's not important anymore if you found the working solution.

Sure, here is the link to the translation that I used as a reference. He translated "Blackwell Legacy" and also mentioned the tools he used, etc. I'm trying to translate "The Shivah," both games were released in late 2006.

Crimson Wizard

Quote from: Mekabor on Fri 19/05/2023 10:10:03
Quote from: Crimson Wizard on Fri 19/05/2023 07:45:58If the other game used different font that contains proper letters with umlauts, that could explain the difference in result.

Then again, the issue may be in a codepage you are saving your TRS, maybe it's not matching the game's font.

I still have the feeling that the mapping of the fonts has been changed because in the .trs file, the umlauts are written as special characters, for example, "ä" is represented as "$" but in the game it is displayed as an umlaut. I'm just wondering how this can be achieved with just a .trs file without making any changes to the game files.

All of this depends on:
- Which letters does the font have and which indexes they use.
- Which letters do you use in TRS and which encoding (utf, ANSI, other) do you save in. The encoding  of your TRS defines the values that letters are going to be represented with. Some letters always save in the value range of 0-127 (this refers to punctuation symbols, and basic latin letters), others will depend on encoding.

For example, if in font they have "ä" in standard place of "$", then you may get to display "ä" simply by putting "$" in the TRS.
For another example, if their font corresponds to ANSI-1252, then your TRS should be saved exactly in ANSI-1252 in order to match all letters.
If they don't have "ä" at all in their game's font, then there's no other way than providing another font.

Here's the archive containing our own command line tools existing so far:
https://www.dropbox.com/s/6wfl3foo3jb9iyu/agstools-360.zip?dl=0
(most of them are only useful when you're compiling the game from sources though)
inside there's a program called agsunpak, it unpacks the AGS game package. It's used from command line like "agsunpak.exe gamefile outputdir". For example: "agsunpak.exe game.exe mydir" or "agsunpak.exe game.ags mydir" (if the game data is in "*.ags" file).

You could use it to get the fonts out of the game and then analyze them using a WFN editor.
One editor may be found here: https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/editor-plugin-wfn-fonteditor/
There has been another older one by Radiant, somewhat easier to use, but I don't have a download link for it.

Mekabor

Quote from: Crimson Wizard on Fri 19/05/2023 17:06:36All of this depends on:
- Which letters does the font have and which indexes they use.
- Which letters do you use in TRS and which encoding (utf, ANSI, other) do you save in. The encoding  of your TRS defines the values that letters are going to be represented with. Some letters always save in the value range of 0-127 (this refers to punctuation symbols, and basic latin letters), others will depend on encoding.

For example, if in font they have "ä" in standard place of "$", then you may get to display "ä" simply by putting "$" in the TRS.
For another example, if their font corresponds to ANSI-1252, then your TRS should be saved exactly in ANSI-1252 in order to match all letters.
If they don't have "ä" at all in their game's font, then there's no other way than providing another font.

Here's the archive containing our own command line tools existing so far:
https://www.dropbox.com/s/6wfl3foo3jb9iyu/agstools-360.zip?dl=0
(most of them are only useful when you're compiling the game from sources though)
inside there's a program called agsunpak, it unpacks the AGS game package. It's used from command line like "agsunpak.exe gamefile outputdir". For example: "agsunpak.exe game.exe mydir" or "agsunpak.exe game.ags mydir" (if the game data is in "*.ags" file).

You could use it to get the fonts out of the game and then analyze them using a WFN editor.
One editor may be found here: https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/editor-plugin-wfn-fonteditor/
There has been another older one by Radiant, somewhat easier to use, but I don't have a download link for it.

First of all, thank you very much for the tools. The agsunpak is very useful. I have tried the Tools and managed to load the .wfn file into the WFN editor.
Now, as you mentioned above, I could simply modify a rarely used character in the editor to the characters I need (the modified characters need to be adjusted accordingly in the .trs file). Then, I would scale it correctly, save it, rename it, and move it to the game folder.
In theory, this should work, right? Or am I missing something in my thinking process?

SMF spam blocked by CleanTalk