determining currently selected language (e.g. english)

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
undersupervised
Newbie
Posts: 1
Joined: Wed Jun 08, 2022 9:10 pm
Contact:

determining currently selected language (e.g. english)

#1 Post by undersupervised » Wed Jun 08, 2022 10:42 pm

I'd like to know what language (translation) is being displayed/rendered to the player at runtime. Currently I have code that includes:

Code: Select all

textbutton _("English") action [ Language(None), SetVariable("persistent.selected_translation", "english") ]
textbutton _("Spanish") action [ Language("spanish"), SetVariable("persistent.selected_translation", "spanish") ]
etc.

In other code I check the "persistent.selected_translation" variable.

This appears to work fine. However I'd prefer to reference some built-in variable that the Language action sets, if that exists. Any thoughts?

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: determining currently selected language (e.g. english)

#2 Post by PyTom » Wed Jun 08, 2022 11:29 pm

It's preferences.language. You can read it, but don't set it, as Language does a lot of work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
m_from_space
Veteran
Posts: 302
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: determining currently selected language (e.g. english)

#3 Post by m_from_space » Thu Jun 09, 2022 4:53 am

PyTom wrote:
Wed Jun 08, 2022 11:29 pm
It's preferences.language. You can read it, but don't set it, as Language does a lot of work.
According to https://www.renpy.org/doc/html/translat ... s.language there is also "_preferences.language". It also works for me, why are there two options?

Post Reply

Who is online

Users browsing this forum: No registered users