

Visual Novel readers and language learners are often looking for Visual Novels where they can switch between languages with a single button press.
This guide builds on our previous RenPy tutorial, How to Add Multiple Languages to Your RenPy Game, so make sure you’ve set up multiple translations in your project before you start. If not, check out that tutorial first.
By the end of this walkthrough, your RenPy game will be able to toggle languages from the quick menu, or with a single keypress or game controller button press.
A full example of a RenPy project with a One Press Language Toggle Button, can be downloaded here.
There are multiple ways a UI can be designed to allow a player to set a toggle language. In this tutorial, are simply going to set the toggle language to the last language (before the current one) that the user had selected.
All of the code for this tutorial can just be added to screens.rpy
. No other files need to be edited.
Let’s add out the Toggle Language script to screens.rpy
:
# TOGGLE LANGUAGE
init python:
# Toggle Language Value
if not persistent.lang_on_toggle:
persistent.lang_on_toggle = "ja"
def set_lang_on_toggle():
lang = renpy.game.preferences.language # get current renpy language
if lang is None:
lang = "en"
# print("lang_on_toggle set to:", lang)
persistent.lang_on_toggle = lang
# Toggle Language: Button Presses
def toggle_text_language():
new_lang = persistent.lang_on_toggle
# Remember the old_lang
set_lang_on_toggle()
# Set language to new_lang
renpy.change_language(new_lang)
# Update Keyboard and Game Controller Bindings
config.keymap["toggle_text_lang"] = [ "l", "L" ]
config.pad_bindings["pad_lefttrigger_pos"] = [ "toggle_text_lang" ]
config.pad_bindings["repeat_pad_lefttrigger_pos"] = [ "toggle_text_lang" ]
# Add Mapping to Toggle Text Language Function
custom_keymap = renpy.Keymap(toggle_text_lang = Function(toggle_text_language))
config.underlay.append(custom_keymap)
‘persistent.lang_on_toggle
toggle_text_language
is triggered, we swap the current language with the toggle language.toggle_text_language
whenever the “L” key, or the Game Controller’s Left Trigger Button is tapped.In screens.rpy
, in screen language_settings()
:
Display the Toggle Language: e.g.
vbox:
style_prefix "radio"
label _("Toggle Language")
text persistent.lang_on_toggle.upper()
Set the Toggle Language right before the current Text Language is updated, e.g.
# Old Language Switching code:
# textbutton "English" action Language("en")
# New Language Swtiching code:
textbutton "English" action [Function(set_lang_on_toggle), Language("en")]
After those changes, your full screen language_settings()
might look something like this (with some prettier labels):
# LANGUAGES DETAILS
init python:
language_details = {
"en": { "name": "English", "font": "NotoSans-VariableFont_wdth,wght.ttf" },
"ja": { "name": "日本語", "font": "NotoSansJP-VariableFont_wght.ttf" },
"ru": { "name": "Русский", "font": "NotoSans-VariableFont_wdth,wght.ttf" },
}
hidden_voice_languages = [] #["ru"]
# LANGUAGE SETTINGS SCREEN
screen language_settings():
tag menu
use game_menu(_("Language"), scroll="viewport"):
hbox:
box_wrap True
vbox:
# TEXT LANGUAGES
vbox:
style_prefix "radio"
label _("Language")
for code, lang in language_details.items():
textbutton lang["name"] text_font lang["font"] action [Function(set_lang_on_toggle), Language(code)]
# TOGGLEABLE TEXT LANGUAGE (with one button press)
vbox:
style_prefix "radio"
label _("Toggle Language")
$ toggleLangDetails = language_details[persistent.lang_on_toggle]
text toggleLangDetails["name"] font toggleLangDetails["font"]
# VOICE LANGUAGES
vbox:
style_prefix "radio"
label _("Voice Language")
for code, lang in language_details.items():
if code not in hidden_voice_languages:
textbutton lang["name"] text_font lang["font"] action [Function(set_voice_lang, code)] selected persistent.voice_lang == code
Finally, add a One-Click Language Toggle Button in the Quick Menu.
In screen quick_menu()
, add one of these options, depending on your preference:
# Display a Language Toggle button with the Language Code
textbutton persistent.lang_on_toggle.upper() action Function(toggle_text_language)
# Display a Language Toggle button with the Language Name
$ toggleLangDetails = language_details[persistent.lang_on_toggle]
textbutton toggleLangDetails["name"] text_font toggleLangDetails["font"] action Function(toggle_text_language) yoffset -4
That’s it! You now have a working One-Click Language Switching Button in your RenPy game! 🎊✨
If you have any questions, or are keen to share what you’ve created (we would love to play your Visual Novel 💖), please reach out!
Copyright © 2025 Omnilingual Access. All rights reserved.