[Tutorial] Creating Translations for Ren'Py Games

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Morhighan
Miko-Class Veteran
Posts: 867
Joined: Sun Jun 27, 2010 12:54 pm
Projects: AIdol
Organization: Pixel Pineberry
Tumblr: MysteryCorgi
itch: pixelpineberry
Contact:

[Tutorial] Creating Translations for Ren'Py Games

#1 Post by Morhighan » Sat Apr 01, 2017 4:50 am

I followed along with this: https://www.renpy.org/doc/html/translation.html
And still managed to find myself repeating mistakes across a few different games. So I decided to make a tutorial

First, you'll want to have a finished script. We'll say it's in English for this example.
Next, you'll want to generate a translation on the main Ren'Py menu with the project selected. We'll use Russian as our example language.

Image
Type in the name of the language and press "Generate Translation" (which I didn't realize was a button at first. ^^; )

Image
Wait for it to make the files and head over to your "game" folder. There will be a new folder, "tl" which will have a folder for your language in it.
So in our case.... "ExampleGame/game/tl/russian"
Your files will be ready for translation. Here's what one of the scripts looks like before:

Image

And After:

Image

Now, make sure that code like this:

Code: Select all

translate russian script1_f978b7f5:

remains capitalized or lowercase to match what is in your folder name. If the folder is "/game/tl/russian" make sure "russian" is always lowercase. Or this happens.
Also make sure to define your characters LIKE THIS or they'll just pop up in English. Example:
Image


Now that the above is done, you should have a functioning translated script. Also make sure to change out any graphics in the GUI if you used imagemaps and add them to "ExampleGame/game/tl/russian/images".


Put the following in options.rpy:

Code: Select all

init -3 python:
    if persistent.lang is None:
        persistent.lang = "english"


    lang = persistent.lang

init python:
    config.main_menu.insert(3, (u'Language', "language_chooser", "True"))


init python:

    if lang == "english":
        style.default.font = "Arimo-Regular.ttf" #your font here
        
    elif lang == "russian":
        style.default.font = "Arimo-Regular.ttf" #your font here

Put the following in script.rpy:
(You can use this label before the game starts so players can choose the language immediately.)

Code: Select all


label language_chooser:
    scene black
    
    menu:
        "{font=Arimo-Regular.ttf}English{/font}":
            $ renpy.change_language(None)
        "{font=Arimo-Regular.ttf}Русский{/font}":
            $ renpy.change_language("russian")

    $ renpy.utter_restart()

Put the following in your imagemap for the Main Menu or Options Menu for screens.rpy:

Code: Select all

hotspot(#,#,#,#) action ShowMenu("language_chooser") #insert coordinates appropriately
And that's how I do it. If you have any helpful tips to add, do let me know. If this helped you at all, also let me know!
ImageImage

User avatar
karorogunso
Newbie
Posts: 6
Joined: Mon Nov 24, 2014 10:01 am
Projects: Bluebird
IRC Nick: karorogunso
Github: karorogunso
Skype: karorogunso
Location: Thailand
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#2 Post by karorogunso » Sat Apr 01, 2017 7:53 am

Also.. you can use this code with SteamAPI too. :D

User avatar
Morhighan
Miko-Class Veteran
Posts: 867
Joined: Sun Jun 27, 2010 12:54 pm
Projects: AIdol
Organization: Pixel Pineberry
Tumblr: MysteryCorgi
itch: pixelpineberry
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#3 Post by Morhighan » Sat Apr 08, 2017 3:45 pm

karorogunso wrote:Also.. you can use this code with SteamAPI too. :D
Good to know/remember that! :D
ImageImage

User avatar
Ertal77
Regular
Posts: 186
Joined: Sat Feb 27, 2016 2:33 pm
Completed: A Hand in the Darkness
Projects: Chasing the Stars
Organization: Ertal Games
Tumblr: ertal77
itch: ertal-games
Location: Spain
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#4 Post by Ertal77 » Wed Jun 14, 2017 6:15 am

Morhighan wrote: Put the following in script.rpy:
(You can use this label before the game starts so players can choose the language immediately.)

Code: Select all


label language_chooser:
    scene black
    
    menu:
        "{font=Arimo-Regular.ttf}English{/font}":
            $ renpy.change_language(None)
        "{font=Arimo-Regular.ttf}Русский{/font}":
            $ renpy.change_language("russian")

    $ renpy.utter_restart()

Thank you so much for this tutorial, it's very clear and useful!
Just a question, though: how do I change the "$ renpy.utter_restart()" part so it goes to my "label start" directly and skips the splashscreen?

*EDIT Nevermind, I changed it for "return" and now it leads me directly back to the game instead of the main menu, but I guess that works fine, too.

User avatar
karorogunso
Newbie
Posts: 6
Joined: Mon Nov 24, 2014 10:01 am
Projects: Bluebird
IRC Nick: karorogunso
Github: karorogunso
Skype: karorogunso
Location: Thailand
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#5 Post by karorogunso » Tue Jul 11, 2017 10:56 pm

Ertal77 wrote:
Morhighan wrote: Put the following in script.rpy:
(You can use this label before the game starts so players can choose the language immediately.)

Code: Select all


label language_chooser:
    scene black
    
    menu:
        "{font=Arimo-Regular.ttf}English{/font}":
            $ renpy.change_language(None)
        "{font=Arimo-Regular.ttf}Русский{/font}":
            $ renpy.change_language("russian")

    $ renpy.utter_restart()

Thank you so much for this tutorial, it's very clear and useful!
Just a question, though: how do I change the "$ renpy.utter_restart()" part so it goes to my "label start" directly and skips the splashscreen?

*EDIT Nevermind, I changed it for "return" and now it leads me directly back to the game instead of the main menu, but I guess that works fine, too.
Yes return is fine too.
Hi.

Kinross07
Newbie
Posts: 7
Joined: Mon May 29, 2017 3:29 am
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#6 Post by Kinross07 » Sun Aug 06, 2017 2:02 am

Unfortunately I don't speak any other language well enough to know myself, how good do the translations tend to be? Is it just utilising something like Google Translate where it makes sense 98% of the time but sometimes completely falls apart?

User avatar
Morhighan
Miko-Class Veteran
Posts: 867
Joined: Sun Jun 27, 2010 12:54 pm
Projects: AIdol
Organization: Pixel Pineberry
Tumblr: MysteryCorgi
itch: pixelpineberry
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#7 Post by Morhighan » Thu Oct 12, 2017 4:55 am

Kinross07 wrote:
Sun Aug 06, 2017 2:02 am
Unfortunately I don't speak any other language well enough to know myself, how good do the translations tend to be? Is it just utilising something like Google Translate where it makes sense 98% of the time but sometimes completely falls apart?
So we hired a team to manually translate the script and then programmed it using the method above. I don't think Ren'Py actually translates anything itself. Though it would be nice.

Hope that helps! :)
ImageImage

Zelan
Eileen-Class Veteran
Posts: 1565
Joined: Tue Mar 01, 2016 7:23 pm
Completed: The Dark
Projects: bookSLEEPer, Stalker & Yandere
Tumblr: evns
itch: Zelan
Contact:

Re: [Tutorial] Creating Translations for Ren'Py Games

#8 Post by Zelan » Thu Oct 12, 2017 7:34 am

This is absolutely fantastic, thank you so much, Morhigan! ^_^

Post Reply

Who is online

Users browsing this forum: No registered users