Displaying different graphics depending on selected translation

Started by Cone Arex, Mon 06/12/2021 17:09:15

Previous topic - Next topic

Khris

Here's a way that doesn't require awkward string comparisons and works with ScummVM:

Code: ags
function room_Load()
{
  String slotString = GetTranslation("2 English language sprite in room 1");
  oLanguage.Graphic = slotString.AsInt;
}


In the translation file you use (text translation optional obviously)
Code: ags
2 English language sprite in room 1
3 Deutsches Sprach-Sprite in Raum 1


Since this only relies on existing and working textual translations, this is 100% guaranteed to work with any environment that supports them.

(If there's going to be dozens of translation specific sprites it's probably better to store the sprite numbers in your code and do the language determination in a function using the above mechanism and a single line)

Crimson Wizard

In regards to the Game.TranslationFilename, to be certain I did another test with a dummy game that displays TranslationFilename on screen. Tried Linux ports for the latest builds of 3.5.0, 3.5.1 and 3.6.0, and all of them work correctly, displaying the selected language...

Cone Arex

QuoteCould you also tell, what version of a linux port are you using and where did you get it, to make sure we're testing same thing?
I just build the game for Linux and then executed the ags64 file. (Is this the right way? I always run into issues with ags and linux.) Version is ACI version 3.5.1.11.

Quote from: Crimson Wizard on Tue 07/12/2021 23:47:01
In regards to the Game.TranslationFilename, to be certain I did another test with a dummy game that displays TranslationFilename on screen. Tried Linux ports for the latest builds of 3.5.0, 3.5.1 and 3.6.0, and all of them work correctly, displaying the selected language...
Strange. I did the same thing and it doesn't.

Crimson Wizard

Quote from: Cone Arex on Wed 08/12/2021 00:08:44
QuoteCould you also tell, what version of a linux port are you using and where did you get it, to make sure we're testing same thing?
I just build the game for Linux and then executed the ags64 file. (Is this the right way? I always run into issues with ags and linux.) Version is ACI version 3.5.1.11.

I think you should run the script with the game's name located one directory above "data", but I don't know if there's much difference.
I usually compile linux engine from the source, but now tried to use editor's feature, and has same (correct) result as before.

Could you upload your game you made for linux for me to check?

heltenjon

I tried Crimson Wizard's method on the Windows version - changed "english" to "English" manually in the config file, confirmed it in setup, and then I got the correct English title screen plus the two other instances. So that fixed it, it seems. However, afterwards I changed it back to "english" in order to reproduce the error again, but now it keeps working correctly, both in German and in English, even with the lower case spelling in config. Go figure. (Windows 10 Enterprise.)

Crimson Wizard

Quote from: heltenjon on Wed 08/12/2021 00:39:22However, afterwards I changed it back to "english" in order to reproduce the error again, but now it keeps working correctly, both in German and in English, even with the lower case spelling in config. Go figure. (Windows 10 Enterprise.)

Are you changing default config in the game dir, or user config in the %USERPROFILE%/Saved Games/<game name>? If you save in winsetup at least once then translation is written to the user config.

heltenjon

Quote from: Crimson Wizard on Wed 08/12/2021 00:52:03
Quote from: heltenjon on Wed 08/12/2021 00:39:22However, afterwards I changed it back to "english" in order to reproduce the error again, but now it keeps working correctly, both in German and in English, even with the lower case spelling in config. Go figure. (Windows 10 Enterprise.)

Are you changing default config in the game dir, or user config in the %USERPROFILE%/Saved Games/<game name>? If you save in winsetup at least once then translation is written to the user config.
Ah! I did it i the game dir.

Cone Arex


Crimson Wizard

Quote from: Cone Arex on Wed 08/12/2021 01:42:04
Quote from: Crimson Wizard on Wed 08/12/2021 00:16:49
Could you upload your game you made for linux for me to check?
https://storage.conequest.de/mmm/ConeArex_TranslationTest_Linux.zip

Well... This starts without translation, but if I set up "english" in acsetup.cfg, run ags64, and it displays "Translation Output: english". If i set it as "English" with capital E, then the title also switches to "Berthold's Return".

Cone Arex

Ahh, now it works. If I set the language manually in acsetup it works with the Linux port. The whole thing was just a mistake of the language not being set correctly. I set the language by Building the exe and then running winsetup through the editor. So the selected language was not written in the acsetup.cfg that the Linux (and probably Android) port use. And I guess ScummVM is using it's own set configs. So, for the foreseeable future I will use a method like Khris suggested, as that should work everywhere.
QuoteIf i set it as "English" with capital E, then the title also switches to "Berthold's Return".
Yeah, I was still using case-sensitive check in the dummy game.  :-[ So that should be an easy fix.

What I still not get is why the actual translated text is still loaded without the language being set correctly in acsetup and how heltenjon got the error under Windows.  ???

In any case, thank you so much for your help!

Crimson Wizard

#30
Quote from: Cone Arex on Wed 08/12/2021 03:28:33I set the language by Building the exe and then running winsetup through the editor. So the selected language was not written in the acsetup.cfg that the Linux (and probably Android) port use.

What you probably need to do instead is use Default Setup page in the editor, available since 3.5.0 also. That specifies the contents of the default config found with the compiled game.
Winsetup only saves user config, which is personal for current OS user (this is how it works since 3.3 or 3.4, the reason is that game may be installed in a read-only location, or where current user does not have write permissions, so winsetup now saves in common user document folders).

But of course this will only create initial config. For having their own players should either edit config file by hand using instructions, or a third-party setup program (I heard some people already made crossplatform ones in the past, but sadly they are not part of AGS distribution still).

Quote from: Cone Arex on Wed 08/12/2021 03:28:33
What I still not get is why the actual translated text is still loaded without the language being set correctly in acsetup

Yes, this confuses me too.

SMF spam blocked by CleanTalk