preferences screen with multiple language option ?

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
User avatar
pratomoastan
Regular
Posts: 39
Joined: Fri Mar 11, 2016 11:39 am
Projects: My High School Life
Organization: After School Things
Deviantart: pratomoastan
Location: Indonesia
Contact:

preferences screen with multiple language option ?

#1 Post by pratomoastan » Tue Jun 28, 2016 5:16 am

i want to make language selection in preferences
so i make :

Code: Select all

 frame:
                style_group "pref"
                has vbox
                
                if lang == "english":
                    label _("Language")
                    textbutton "English" $persistent.lang = ("english")
                    textbutton "Indonesia" $persistent.lang = ("indonesian")
                    textbutton "日本語" $persistent.lang = ("japanese")
                    
                elif lang == "indonesian"
                    label _("Bahasa")   
                    textbutton "English" $persistent.lang = ("english")
                    textbutton "Indonesia" $persistent.lang = ("indonesian")
                    textbutton "日本語" $persistent.lang = ("japanese")
                    
                elif lang == "japanese"
                    label _("言語")
                    textbutton "English" $persistent.lang = ("english")
                    textbutton "Indonesia" $persistent.lang = ("indonesian")
                    textbutton "日本語" $persistent.lang = ("japanese")

and this what i got :

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 406: expected a keyword argument, colon, or end of line.
    textbutton "English" $persistent.lang = ("english")
                         ^

Ren'Py Version: Ren'Py 6.99.10.1227

also i want the user asked what language that they want every game start
so i do :

@script.rpy

Code: Select all

label language_chooser:
    scene black
    
    menu:
        "{font=font/sansani.otf}English{/font}":
            $ persistent.lang = "english"
        "{font=font/sansani.otf}Indonesian{/font}":
            $ persistent.lang = "indonesian"
        "{font=font/mikochan.otf}日本語{/font}":
            $ persistent.lang = "japanese"

    $ renpy.utter_restart()
    
    
label splashscreen:

    $ renpy.movie_cutscene('movie/splash.ogv', delay=None)
    if not persistent.chose_lang:
        $ persistent.chose_lang = True
        jump language_chooser

    return

@option.rpy

Code: Select all

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

    lang = persistent.lang

## This section contains information about how to build your project into
## distribution files.
init python:
    
    config.main_menu.insert(3, (u'Language', "language_chooser", "True"))

@script.rpy
====================
label start:
    
    $ renpy.movie_cutscene('movie/introduce.ogv', delay=None, loops=0, stop_music=True)
    $ game_lang = lang
    
    if lang == "indonesian":
         jump startid
    
    elif lang == "english":
         jump starten
    
    elif lang == "japanese":
         jump startjp

but if the game closed and started again the game wont ask what language that players want ><
~ Sempai !!!

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: preferences screen with multiple language option ?

#2 Post by korova » Tue Jun 28, 2016 6:03 am

I think I have a solution for your preference menu issue : you have to use screen language to achieve what you want, not persistent variable.
You have a screen language action to change language
https://www.renpy.org/doc/html/translat ... -variables

So you should change your code for something like that

Code: Select all

frame:
                style_group "pref"
                has vbox
               
                if lang == "english":
                    label _("Language")
                    textbutton "English" action Language("english")
                    textbutton "Indonesia" action Language("indonesian")
                    textbutton "日本語" action Language("japanese")
and so on.

For your second problem, I'm not totally sure I understand what you want to achieve, but what I understand is :

In the splashscreen label, you test a variable called persistent.chose_lang.
If False, you play the language_choser label AND set the persistent.chose_lang variable to True.
So, next time you open the game, persistent.chose_lang is True (this is how persistent variables work, they remain even when you close the game), so the language_choser label is not played.

Hope it helped a little.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1919
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: preferences screen with multiple language option ?

#3 Post by Donmai » Tue Jun 28, 2016 7:47 am

Ren'Py expects each game to be written in a single primary language. This is called the None language, regardless of what language it actually is.
https://www.renpy.org/doc/html/translat ... ranslation
See the Ren'Py tutorial game screens.rpy for an example of a preferences screen with language selection.
To put a language selection menu on the splash screen: viewtopic.php?p=255947#p255947
Last edited by Donmai on Tue Jun 28, 2016 2:28 pm, edited 1 time in total.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
pratomoastan
Regular
Posts: 39
Joined: Fri Mar 11, 2016 11:39 am
Projects: My High School Life
Organization: After School Things
Deviantart: pratomoastan
Location: Indonesia
Contact:

Re: preferences screen with multiple language option ?

#4 Post by pratomoastan » Tue Jun 28, 2016 8:39 am

Code: Select all

label after_load:
    if lang == game_lang:
        return

    if lang == "english":
        "The language of the save file is not the current selected language."
    elif lang == "japanese":
        "ファイルを保存した言語は、現在の選択された言語ではありません。"

    $ renpy.full_restart()

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 218, in script call
    python:
  File "game/script.rpy", line 139, in script call
    if lang == game_lang:
  File "game/script.rpy", line 139, in script call
    if lang == game_lang:
  File "game/script.rpy", line 139, in script
    if lang == game_lang:
  File "game/script.rpy", line 139, in <module>
    if lang == game_lang:
NameError: name 'lang' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/00start.rpy", line 218, in script call
    python:
  File "game/script.rpy", line 139, in script call
    if lang == game_lang:
  File "game/script.rpy", line 139, in script call
    if lang == game_lang:
  File "game/script.rpy", line 139, in script
    if lang == game_lang:
  File "C:\Users\Pratomo Asta N\Downloads\Programs\renpy-6.99.10-sdk\renpy\ast.py", line 1648, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\Pratomo Asta N\Downloads\Programs\renpy-6.99.10-sdk\renpy\python.py", line 1606, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\Pratomo Asta N\Downloads\Programs\renpy-6.99.10-sdk\renpy\python.py", line 1601, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 139, in <module>
    if lang == game_lang:
NameError: name 'lang' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.10.1227
mhsl 5.0
~ Sempai !!!

Post Reply

Who is online

Users browsing this forum: No registered users