How to toggle between languages in-game?

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
VisualLearning
Newbie
Posts: 12
Joined: Thu Jan 07, 2016 4:30 am
Contact:

How to toggle between languages in-game?

#1 Post by VisualLearning » Thu Jan 07, 2016 4:38 am

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.

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: How to toggle between languages in-game?

#2 Post by Donmai » Thu Jan 07, 2016 5:25 am

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. :)
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

VisualLearning
Newbie
Posts: 12
Joined: Thu Jan 07, 2016 4:30 am
Contact:

Re: How to toggle between languages in-game?

#3 Post by VisualLearning » Thu Jan 07, 2016 6:43 am

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.

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: How to toggle between languages in-game?

#4 Post by Donmai » Thu Jan 07, 2016 12:46 pm

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.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

VisualLearning
Newbie
Posts: 12
Joined: Thu Jan 07, 2016 4:30 am
Contact:

Re: How to toggle between languages in-game?

#5 Post by VisualLearning » Thu Jan 07, 2016 1:40 pm

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?

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: How to toggle between languages in-game?

#6 Post by Donmai » Thu Jan 07, 2016 5:06 pm

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 ("").
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

VisualLearning
Newbie
Posts: 12
Joined: Thu Jan 07, 2016 4:30 am
Contact:

Re: How to toggle between languages in-game?

#7 Post by VisualLearning » Fri Jan 08, 2016 2:29 am

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.

Post Reply

Who is online

Users browsing this forum: Ocelot