How to change the initial 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
DarkLimone
Newbie
Posts: 3
Joined: Fri Apr 17, 2020 4:34 am
Contact:

How to change the initial language?

#1 Post by DarkLimone »

How to change the initial language?
I have tried with, in screens :

Code: Select all

init -3 python:
    if persistent.lang is None:
        persistent.lang = "english"
    lang = persistent.lang

but it does not work

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: How to change the initial language?

#2 Post by xavimat »

"persistent.lang" is not a renpy variable. Neither "lang" is. Those variables don't do anything to the translation system of renpy.

1. You need a None language, that is the original language the game is created. I'm assuming your game is not in originally in English.

2. Usually we put a "change language" option in the preferences screen. Look at the screen.rpy file. You can add the following:

Code: Select all

vbox:
    style_prefix "check"
    label _("Language")
    textbutton "Original language" action Language(None)
    textbutton "English" action Language("english")
3. It's usual to ask the player's preferred language, the first time they open the game. You can do that this way:

Code: Select all

label splashscreen:
    if not persistent.lang_selected:
        menu:
            "Original language":
                $ persistent.lang_selected = True
            "English":
                $ persistent.lang_selected = True
                $ renpy.change_language("english")
    return
Here, you see the persistent.lang_selected variable. It does nothing to the translation itself, only ensures that this menu is shown only once (the first time the game is executed).
The functions and actions that actually renpy uses for the selection of language are: renpy.change_language(), Language()
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Kia