Change language in screen's text

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
neometalero
Regular
Posts: 196
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Change language in screen's text

#1 Post by neometalero »

I'm using this code for changing the language on my screen, but it doesn't work when I change the language. Always show the none option. What I'm doing wrong?

Code: Select all

vbox:
            if Language(None):
                text _("{color=#F313E4}Points:{/color} ") + str(g.points) size 24
                text _("{color=#F313E4}Time:{/color} ") + str(g.duration) size 24
            else:
                text _("{color=#F313E4}Puntos:{/color} ") + str(g.points) size 24
                text _("{color=#F313E4}Tiempo:{/color} ") + str(g.duration) size 24
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Change language in screen's text

#2 Post by _ticlock_ »

Hi, neometalero,

Your example is not how the RenPy translation system works.
The construction _("") you are using is necessary for the RenPy translation system to recognize that this string should be translated. For your screen you need only:

Code: Select all

vbox:
    text _("{color=#F313E4}Points:{/color} ") + str(g.points) size 24
    text _("{color=#F313E4}Time:{/color} ") + str(g.duration) size 24
Then you can generate translation files in the RenPy launcher. (Check doc and this cookbook for more info and example).

In your generated translation file that is located in tl/<language>/<name_of_file.rpy> you should have something like:

Code: Select all

# game/script.rpy:<line number>
    old "{color=#F313E4}Points:{/color} "
    new "{color=#F313E4}Points:{/color} "
    
# game/script.rpy:<line number>
    old "{color=#F313E4}Time:{/color}  "
    new "{color=#F313E4}Time:{/color} "
old show default language string, and new string you replace with translated string

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: Change language in screen's text

#3 Post by Jackkel Dragon »

Another note with translating displayables (as opposed to dialogue): some displayables only update on the next interaction. This means changing languages while that text is displayed requires rolling back to update the language. Using translation strings should prevent this in most cases, while the original code you have may require rolling back to work.
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
neometalero
Regular
Posts: 196
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Change language in screen's text

#4 Post by neometalero »

_ticlock_ wrote: Thu Feb 04, 2021 2:12 pm Hi, neometalero,

Your example is not how the RenPy translation system works.
The construction _("") you are using is necessary for the RenPy translation system to recognize that this string should be translated. For your screen you need only:

Code: Select all

vbox:
    text _("{color=#F313E4}Points:{/color} ") + str(g.points) size 24
    text _("{color=#F313E4}Time:{/color} ") + str(g.duration) size 24
Then you can generate translation files in the RenPy launcher. (Check doc and this cookbook for more info and example).

In your generated translation file that is located in tl/<language>/<name_of_file.rpy> you should have something like:

Code: Select all

# game/script.rpy:<line number>
    old "{color=#F313E4}Points:{/color} "
    new "{color=#F313E4}Points:{/color} "
    
# game/script.rpy:<line number>
    old "{color=#F313E4}Time:{/color}  "
    new "{color=#F313E4}Time:{/color} "
old show default language string, and new string you replace with translated string
Renpy didnt generated translations for those items on the screen, that why I tryied to to it by hand
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
neometalero
Regular
Posts: 196
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Change language in screen's text

#5 Post by neometalero »

Jackkel Dragon wrote: Thu Feb 04, 2021 3:27 pm Another note with translating displayables (as opposed to dialogue): some displayables only update on the next interaction. This means changing languages while that text is displayed requires rolling back to update the language. Using translation strings should prevent this in most cases, while the original code you have may require rolling back to work.
Tks, I didnt knew that about displayables. Will check if rolling back works.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]