Page 1 of 1

Define Carracter with condition.

Posted: Thu Apr 18, 2019 11:20 am
by Hoseigndie
Hello all,

This is my problem. I want to make a multi-language games.
This is my exemple code for dialogue in the game :

bob "[dia1]"

and this is my code for dialogue :

define dia1 = Character("Hello!")
define dia2 = Character("Very nice...")
etc ...

I have a option in the beginning (for english_langu or french_langu). I want to change the "dia1" with condition. I test this code but it disn't work ....

if english_langu:
define dia1 = Character("Hello!")
define dia2 = Character("Very nice...")

if french_langu:
define dia1 = Character("Bonjour!")
define dia1 = Character("Très jolie...")


Sorry for my english ...

Re: Define Carracter with condition.

Posted: Thu Apr 18, 2019 8:13 pm
by plaster
Have you looked at Ren'Py's built-in translation framework? Just write everything in one language:

Code: Select all

bob "Hello!"
bob "Very nice..."
... and then when you're done, click Generate Translations in the launcher and make a translation called "french". Then in game/tl/french you'll see a copy of the game's scripts. You can edit those and fill in your French translations, which will look something like this when you're done:

Code: Select all

translate french strings:

    old "Hello!"
    new "Bonjour!"

    old "Very nice..."
    new "Très jolie..."
Then instead of your custom language variable, use _preferences.language to get the current language name ("french" or None for English). You can change the language in the script with renpy.change_language("french") or from a screen using action Language("french")

Re: Define Carracter with condition.

Posted: Fri Apr 19, 2019 3:30 am
by Hoseigndie
Thx, I will see that ;)