Variable for game language

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
agl
Regular
Posts: 54
Joined: Tue Jul 19, 2016 5:09 am
Contact:

Variable for game language

#1 Post by agl »

Hello. I am creating a game with two languages. There is no problem with mundane text translation. But sometimes I need the variable thish determines the language game used. Something like that:

Code: Select all

    if language == "english":    
        $ hero_name = renpy.input("Who am I?", default="John Dow")           
    else:
        $ hero_name = renpy.input("Кто я?", default="Джон")  
The language chosen as:

Code: Select all

            frame:
                style_prefix "pref"
                has vbox

                label _("Language")
                textbutton "English" action Language("english")
                textbutton "Russian" action Language(None) 

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Variable for game language

#2 Post by Divona »

The variable you're looking for is:

Code: Select all

_preferences.language
On a side note. I would suggest you use:

Code: Select all

$ hero_name = renpy.input(_("Who am I?"), default=_("John Dow"))
Then use Ren'Py build in Translation to assign different text in those line. No need to setup those 'if/else'. Make life easier. :D
Completed:
Image

agl
Regular
Posts: 54
Joined: Tue Jul 19, 2016 5:09 am
Contact:

Re: Variable for game language

#3 Post by agl »

Thank you very much. It is much more easier )

Post Reply

Who is online

Users browsing this forum: Google [Bot]