Translation not working when string contains \n

Started by Manu, Sun 16/05/2021 09:06:19

Previous topic - Next topic

Manu

I finally finished translating my first game. The problem is every time the string has a "\n", for example:

Code: ags

INSTRUCTIONS\n\nClick anywhere to move the character


the translation is ignored and the default language appears. How to make translations work when there is a \n ?

eri0o

I know AGS also allows using [ as \n character for some reason I never understood why, but now that you asked, can you check if replacing \n with [ for one of you're cases fixes it?

Manu

Quote from: eri0o on Sun 16/05/2021 09:15:03
can you check if replacing \n with [ for one of you're cases fixes it?

Yes, it works! Thanks a lot!

I noticed another thing. If I change a text in the game, then I select "update translation", I can see new lines are added to translation.trs. The original lines are still there, even if they won't be used anymore. Is it normal? Should I delete them manually?

Crimson Wizard

#3
Frankly this sounds like a bug... I'd rather test this through and find out why "\n" does not work.


Quote from: emabolo on Sun 16/05/2021 09:56:49
I noticed another thing. If I change a text in the game, then I select "update translation", I can see new lines are added to translation.trs. The original lines are still there, even if they won't be used anymore. Is it normal? Should I delete them manually?

Yes unfortunately that's how it's made to work at the moment.

I think it's safe to delete unused lines, so long as you delete a pair of lines each time to keep TRS format correct (odd lines are original and even lines are translations). It's just that this may become tiresome as your game text grows.

Manu

Quote from: Crimson Wizard on Sun 16/05/2021 11:34:36
Frankly this sounds like a bug... I'd rather test this through and find out why "\n" does not work.
In all the lines with \n, the game only shows the original version, not the translation. I replaced all of them with "[" and it works. Not sure what I should test. Seems like a bug of AGS, or \n was not supposed to be used.

Quote from: Crimson Wizard on Sun 16/05/2021 11:34:36
Yes unfortunately that's how it's made to work at the moment.

I think it's safe to delete unused lines, so long as you delete a pair of lines each time to keep TRS format correct (odd lines are original and even lines are translations). It's just that this may become tiresome as your game text grows.

Yes in fact it's quite annoying. It would be better at this point to manage all texts in an external file, not just the additional languages. Maybe there should be a feature to replace all the hardcoded text with placeholders/variable names such as %STRING1%, and then you change both languages in the trs file. Just an idea.

Crimson Wizard

Quote from: emabolo on Sun 16/05/2021 14:45:50
Quote from: Crimson Wizard on Sun 16/05/2021 11:34:36
Frankly this sounds like a bug... I'd rather test this through and find out why "\n" does not work.
In all the lines with \n, the game only shows the original version, not the translation. I replaced all of them with "[" and it works. Not sure what I should test.

Sorry, I did not mean that you should be testing, I meant the AGS developers should investigate this out to see what's wrong.

Manu

Quote from: Crimson Wizard on Sun 16/05/2021 14:48:25
Sorry, I did not mean that you should be testing, I meant the AGS developers should investigate this out to see what's wrong.

Ah ok, no problem  :)

Last question. When I zip the Windows folder and I send it to someone else. Will this person start the game in the Default language, or it will be in the last language I played the game? Are the last settings saved in the config file?

Crimson Wizard

#7
Quote from: emabolo on Sun 16/05/2021 15:13:20
Last question. When I zip the Windows folder and I send it to someone else. Will this person start the game in the Default language, or it will be in the last language I played the game? Are the last settings saved in the config file?

The config file in Compiled folders is called "default config", and its options are set up using "Default Setup" panel in the Editor. This config is never changed by running the game.

When you (or your players) run setup program and apply new options - these are written to the "user config" in %USERPROFILE%/Saved Games/<your game name>.

Manu

Quote from: Crimson Wizard on Sun 16/05/2021 15:25:03
The config file in Compiled folders is called "default config", and its options are set up using "Default Setup" panel in the Editor. This config is never changed by running the game.

I see, ok. So if I want to distribute two versions of the game, one with default English and another one with another default, I can change the Default Setup, then build all files, zip the files and name the archive -en.zip, then change the Default again, and re-build all files, and zip a second version, right?

Crimson Wizard

Quote from: emabolo on Sun 16/05/2021 15:35:06
So if I want to distribute two versions of the game, one with default English and another one with another default, I can change the Default Setup, then build all files, zip the files and name the archive -en.zip, then change the Default again, and re-build all files, and zip a second version, right?

Yes. But of course you can also edit acsetup.cfg by hand. There are instructions to what may be inside:
https://github.com/adventuregamestudio/ags-manual/wiki/RuntimeEngine#configuration-file-options


Crimson Wizard

#11
Yes, I confirm, the Editor does not save "\x" sequences correctly for translations, only sequences like "\\" and "\"".

I will add this fix to 3.5.1 beta.

Manu

Quote from: Crimson Wizard on Mon 17/05/2021 00:57:09
Yes, I confirm, the Editor does not save "\x" sequences correctly for translations, only sequences like "\\" and "\"".
I will add this fix to 3.5.1 beta.

That's great! I'm glad I helped to spot a bug.
Maybe it could be a good idea also to comment all the unused lines. So, when I select "update translation", all the file is checked and if a string is not found in the entire game, the line and corresponding translation are commented. This would help to keep the translation file clean. The reason why I suggest commenting instead of removing the lines is that this way you can copy and paste the translation from the unused lines.

Grundislav

Sorry to dig up an old thread, but it seems like this bug still exists. I have several dialogue options where actions are indicated with square brackets, i.e.

[Lie] I don't know what you mean.

In order to display correctly, I have to add a \ before the opening bracket, otherwise the bracket is treated as a line break.

However, the translation ignores the string because it starts with \

The workaround has been to replace all the square brackets with parentheses, but if there's a fix that would be great.

Crimson Wizard

#14
Quote from: Grundislav on Thu 13/03/2025 12:47:48In order to display correctly, I have to add a \ before the opening bracket, otherwise the bracket is treated as a line break.

However, the translation ignores the string because it starts with \

This seems to be an opposite problem compared to the one reported here earlier. Translation compiler tries to resolve escaped sequences like "\n", but when it finds "\[" sequence it does not consider that a valid standard escape sequence, so turns it into "[". This causes mismatches with the original line in game.

Crimson Wizard

@Grundislav , I made a fix for 3.6.1 and 3.6.2 versions, will you require this for 3.6.0, or you have decided to go with your workaround?

Grundislav

Appreciate it, but I think we're going to stick with the workaround. But good to know it will work next time :)

SMF spam blocked by CleanTalk