Page 1 of 1
How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 4:38 am
by VisualLearning
I want to have buttons in-game that easily let's you toggle between English, Japanese and Japanese with furigana.
How can this be implemented? How do I write the code for each "language"?
Am I posting the right place of the forum? I am new here.
Re: How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 5:25 am
by Donmai
Welcome. Yes, you are on the right place, but that's a too complex topic to be explained in a simple answer. You will find the documentation on translations here:
http://www.renpy.org/doc/html/translati ... ranslation
For an example of it's usage, see the Ren'Py Tutorial game, it's a multilanguage project.
If you have any doubts, come back and ask whenever you want.

Re: How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 6:43 am
by VisualLearning
Thank you.
I have copied this into the menu:
Code: Select all
frame:
style_group "pref"
has vbox
label _("Language")
textbutton "日本語" action Language(None)
textbutton u"furigana" text_font "Chihaya.ttf" action Language("furigana")
textbutton u"English" text_font "Chihaya.ttf" action Language("English")
When I change the language to either furigana or English all the buttons in the menu loses their text except 日本語 and furigana. Even the word English doesn't display. I have tried playing around with different fonts but it hasn't helped. I don't mind that all buttons are in English.
Also, in the beginning I let users choose the language with menu and renpy.change_language("English") or renpy.change_language(None) both give me the error: Expected statement.
Re: How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 12:46 pm
by Donmai
Just wide guessing: problem A is looking font related. Your font may be lacking a complete set of international characters. I believe OTF fonts also work with Ren'Py. Problem B may be case related. Have you defined the language name as English or english? In any case, the default language of your game will be referenced as None.
Re: How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 1:40 pm
by VisualLearning
Not really a font issue cause:
1. I have tried with other fonts and I still get the same error where if I choose alternative language
2. The default is Japanese and it manages to show the buttons in English without problem.
3. Using a different font for English does show the word English on the change-language button in that font but as soon as you click it all the boxes become wordless.
4. The in-game text appears correctly with the font. Only the buttons do not show text if another language is chosen.
The second issue is not caused by case mismatch since I did define it as English and the code renpy.change_language(None) throws an error which is should not. Well, this doesn't really matter but I wanted to mention it.
So how can I get help when I am stuck? Is it possible to attach the files as a zip and have it looked at? If yes, what should I use to upload?
Re: How to toggle between languages in-game?
Posted: Thu Jan 07, 2016 5:06 pm
by Donmai
Oh, sorry! It was so obvious that I just forgot to mention it: have you edited the translation .rpy files inside your tl/language folders? By default the translation files are created as empty strings ("").
Re: How to toggle between languages in-game?
Posted: Fri Jan 08, 2016 2:29 am
by VisualLearning
Thank you. I had to translate common.rpy and not only script.rpy.
I am having other problems such as selecting a different language still shows me Japanese strings for some sentences and English for others.
I think it will be easier to write the whole game in Japanese first and then generate translations in the end.
Thanks.