Tool RenPy Translation tool

5.00 star(s) 4 Votes

v01d_08

Member
Modder
Jan 2, 2018
233
304
screen.png
Latest version: Translate RenPy 0.08


Development and thread are ABANDONED !!!


Hi guys, I've created a tool for Windows, that helps to tranlste RenPy games, called TranslateRenPy.
It will help you to change language in your RenPy game. Currently it can grab all untranslated dialogues from the game to one file, so you can more easily translate it manually, or you can translate it with online translator (using this tool and online API), and then export all translated dialogues back into the game. Tnen just add several lines of code to create a custom menu, and you will be able to change language in your RenPy game.

Generate RenPy translations

At first, let me point that the tool works only with dialogues. The , which is used in some visual novels, is currently not supported. But it is really rare case, so you probably would not need it.

Now let's start. First, we need to setup everything, it may take you about 20 min, but this required to do only for the first time.
To work with translations, I assume that you have the RenPy engine installed. If not, go to and download the latest version. Then copy your RenPy game to the folder with RenPy sdk, so it looks like on screen below.

screen2.png

Then download version 0.9, press 1 (Extract RPA) and wait untill all is extracted, then press 1 to return to menu, and then 2 (Decompile rpyc). After all done, go to the directory with you game, navigate to 'game' folder, and remove all files starting with 'UnRen'.
Now execute RenPy engine from sdk folder, select your project and press Generate Translations. Type your language name and select 'Generate empty strings'. Press Generate Translations, like on screen below. Navigate to YouGameFolder\game\tl, and there you should see a folder, which name you typed when generation translations on previous step.

screen3.png

Grabbing dialogues and manual translation

Remark: If you want to do online translation, you can jump to next step "Online translation".
After you are done, execute this tool from any place. Copy global path of your folder with translations, for example C:\renpy-7.1.3-sdk\Milfy_City-0.5c-pc\game\tl\russian into the tool. Press 'Generate translations file', and if you done everywhing correct, the file 'translations.txt' will be generated near the executable of this tool. Open it, and you will see lines like this:

# scripts\beach\Beach_Event\MLR3_beach_cliff.rpy #6
# Mom "Have you ever been cliff jumping before?"
Mom ""

The first line is used by the tool, it should not be changed. The second line is original dialogue, and the third is empty translation. You should type the text between two double quotes. This 3 lines should not be separated by empty lines, it is required for a stable work of this tool.

After you done manual translation, you may want to import dialogues back into the game. Save the changes in translations.txt, and press the button 'Export dialogues from translation file'. The tool will export all non-empty translated dialogues back to the game, and remove them from the file.

Online translation

The online translation is performed via Google. To use Google Translation API you must create a Google Cloud account and add you credit card to activate the account. Also there is a complicated alternative way of creating an account, if, for some reason, you failed to add a credit card. For detailed instructions see the file Translate.API.pdf attathed to this thread or near the tool's executable.

So once you setup your account and finished the translation with the tool, a 'completed' message appear, check the file translations.txt (located near the tool's executable), it should have all lines translated. Pay attention to 'Total dialogues' and 'Dialogues translated' labels to make sure there were no issues during translation. If all dialogues are not translated, then some errors occurred during API requests, just click 'Translate' button again, and the Tool will complete with remaining dialogues. After you are done, export dialogues back to game by pressing the 'Export dialogues' button. It can take some time, in case you don't have SSD disk, be patient.
Now you have all dialogues translated and located in YourRenPyGame\game\tl\yourlang directory. If any errors occur, the tool will show you the line number in translations.txt file and a short description of this error.

Modifying the game preferences

After all done, we need to make possible for user to change translation using RenPy change language feature.
(If the way below is too difficult to you, and you failed it, or you don't understand how to do it - see Q/A section, there is an alternative way.)
Go to the directory with you game, navigate to 'game' folder, and open file screens.rpy in your text editor (sometimes this file located in 'game/scripts' folder). Find the text
use game_menu(_("Preferences")
After it, try to find
if renpy.variant("pc")
it should be located in that 'preferences' section. If there is no such line, find 'hbox' or 'vbox' or 'frame' and insert next code after it, starting from new line (please note, that the number of spaces is important! see screen below. Tab symbols are not allowed by RenPy, use only spaces! Also change 'Russian' to your language, and the second 'russian' exactly to the name of folder with your translations, case sensitive). But keep in mind, that screens.rpy is unique in every game, so there is no exact scenario, how to modify it. You are responsible for this on your own. The main idea is to insert a block, similar to existing, and add 2 textbuttons.

Python:
vbox:
    style_prefix "pref"
    label _("Language")
    textbutton "English" action Language(None)
    textbutton "Russian" action Language("russian")
or if your preferences screen contains frames:
Python:
frame:
    style_prefix "pref" #or any other style depending on your code
    has vbox: #add if your frame is inside vbox section
        xfill True #add if your frame is inside vbox section
    label _("Language")
    textbutton "English" action Language(None)
    textbutton "Russian" action Language("russian")
screen4.png screen5.png

Failed to change game preferences? Don't forget about Q/A section in this post, there is an alternative way.

Now start the game (the best way to click 'Launch Project' from RenPy engine, so if there are any errors in translation files, the engine will show them to you). In the game click on Preferences (or similar label) in main menu of the game, and you will see the Language section on Preferences tab. So you are able to change the language now (if the label with the name of your language is disabled, probably the name of the folder with translations and the string with lang name in screens.rpy do not match). If you changed the language - congratulations.
You can give the folder with translations and a file screens.rpy to any person who has the same version of the game, and it will work like a charm.
Of course the machine translation is not the same as human, but sometimes it is much better than nothing.
This RenPy Translation tool requires runtime libraries to be installed, if you failed to start this tool on your PC, install it.
. The program is packed with .net packer, so several engines consider it as unsafe with low score, please don't pay attention.
If you found any issues - please report them here with Log.txt file, which is located near executable.

For those, who want to better understand how RenPy translation process works - I recommend to read this tutorial by member moskyx: Translating Ren'Py games: a comprehensive guide.

If you used this tool to translate a game - please leave a comment about your experience in this thread.
Created a post about translation at F95zone? Leave a link to this thread, so other people know it exists.

You don't have permission to view the spoiler content. Log in or register now.
You don't have permission to view the spoiler content. Log in or register now.
You don't have permission to view the spoiler content. Log in or register now.
 
Last edited:

Xorgroth

Well-Known Member
Modder
Oct 12, 2017
1,090
1,116
Hmm, maybe I'm having a stupid moment or something but if I try to use this tool to go from Russian to English, it will just put Russian in there. Won't even attempt to translate the line, however if I try English to Russian it seems to work just fine.
For example... using ru-en and my api key.
Code:
    old "Поиграем с соском"
    new "Поиграем с соском"
 

v01d_08

Member
Modder
Jan 2, 2018
233
304
Hmm, maybe I'm having a stupid moment or something but if I try to use this tool to go from Russian to English, it will just put Russian in there. Won't even attempt to translate the line, however if I try English to Russian it seems to work just fine.
For example... using ru-en and my api key.
Code:
    old "Поиграем с соском"
    new "Поиграем с соском"
Hello, thanks for your comment. Indeed, there was a bug, the language text box had no effect. Please re-download attached zip archive, I've fixed it. Also don't forget to generate a new translations.txt file, in case the old one is filled with wrong translations.

Also please note, that if original string has single quotes, Yandex can change it to double quotes during translation. In this case use the button 'Fix double quotes', because RenPy does not allow more than 2 double quotes in one dialogue. For example
"Give me 'Book of the books' please",
Yandex will translate it like:
"Дай мне "Книгу всех книг" пожалуйста" - see, to much double quotes. Just press the button and the tool will automatically fix it.
 

agonzlop

New Member
Nov 5, 2017
8
1
hello everything works fine to translate from English to Spanish but when trying to generate the file to export it gives me error
 
  • Like
Reactions: Kayakash

seemes

Newbie
Nov 18, 2018
17
0
help me please I get this error how can I fix it.

help me please :(

I fix it this and I have so many error...

You don't have permission to view the spoiler content. Log in or register now.


What is this
 

v01d_08

Member
Modder
Jan 2, 2018
233
304
hello everything works fine to translate from English to Spanish but when trying to generate the file to export it gives me error
Hello, I didn't know that # symbol can occur after the opening brace, so the tool considers it as illegal symbol. I've fixed it.
Also I have add the programmatically handling of situation with tags translation. Now even if Yandex translated the text in tag, it will be automatically taken from original line. And updated the first post.

Ketamine, you have the same issue.

I fix it this and I have so many error...
As already pointed above - RenPy forbids tab symbols. Also before runing the game I recomend to check scripts in RenPy engine - just click "Check Script (Lint)" from RenPy main window to know, if you did everything right.

Uploaded a new version 0.2. Please re-download the tool.
Also I recomend to generate translations from RenPy again to prevent any issues. Just to be sure that you have clean files.

P.S. Guys, please tell me if you have any more issues.
 
  • Like
Reactions: Ketamine

v01d_08

Member
Modder
Jan 2, 2018
233
304
And this error after I inserted vbox code :(
Ok looks like the spacing was wrong, I've updated first post, please try to use different amount of spaces, see the new image in section "Modifying the game preferences". I've just tried your variant (but with new amount of spaces) in my game and it worked.
 
  • Like
Reactions: Ketamine

Ketamine

New Member
May 15, 2018
5
2
Ok looks like the spacing was wrong, I've updated first post, please try to use different amount of spaces, see the new image in section "Modifying the game preferences". I've just tried your variant (but with new amount of spaces) in my game and it worked.
I got it. Thank you so much.
My last question.
Can you add the translation feature by Google Translate?
 
  • Like
Reactions: The Evil Zurg

v01d_08

Member
Modder
Jan 2, 2018
233
304
I'm glad it worked for you. Yes, in future I plan to add Google Translate, but I can't give any time frames, cos I work on this tool after work in my free time.
 

revoluta

New Member
Dec 15, 2018
10
3
62.jpg

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at LxLPjl9vPQCxg0DE9I.DxMCVPQTrlt7l1nGQR.gA4TWEauv(String[] )
at LxLPjl9vPQCxg0DE9I.DxMCVPQTrlt7l1nGQR.lm0nMDXLI(String[] , String )
at TranslateRenPy.FormMain.nKDuuedes(Object , EventArgs )
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3260.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
TranslateRenPy
Assembly Version: 0.2.0.0
Win32 Version: 0.2.0.0
CodeBase: file:///C:/Users/Modern/Downloads/TranslateRenPy/game/scenes/TranslateRenPy.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3260.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3260.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.



----------------------------------------
Click the "Generate translation file"

Is that Netframework error?
 

v01d_08

Member
Modder
Jan 2, 2018
233
304
revoluta, thanks for your comment, looks like you found a bug. I've fixed it, please redownload the tool and try again.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,110
14,782
Hello, I didn't know that # symbol can occur after the opening brace, so the tool considers it as illegal symbol. I've fixed it.
Er... Absolutely all the characters, and the unicode table have many of them, can occur after the opening brace. Even a Carriage Return can occur, and probably also a tabulation. The only rule you should have here is "if the character is the same than the opening one, then it must be escaped to be part of the string."
And since I talk about this, is your tool working with the Monologue mode ?
 

v01d_08

Member
Modder
Jan 2, 2018
233
304
Er... Absolutely all the characters, and the unicode table have many of them, can occur after the opening brace. Even a Carriage Return can occur, and probably also a tabulation. The only rule you should have here is "if the character is the same than the opening one, then it must be escaped to be part of the string."
Thanks for the detailed reply, but I am not sure there can be 2 opening braces, as long as all unicode characters after opening brace. RennPy will not hadle it.

And since I talk about this, is your tool working with the Monologue mode ?
Looks like the answer is "no", because I didn't know about this feature. I will try add it to future update tomorrow, thanks for paying your attention to this.
 
  • Like
Reactions: User #19006

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,110
14,782
[...] but I am not sure there can be 2 opening braces, as long as all unicode characters after opening brace. RennPy will not hadle it.
Ren'py will see as a string this :
'this is a string'
as well as this :
"this is also a string"
And in both the starting character can be present, as long as it's escaped :
'Let\'s test this'
"He said \"Let's test this\""
Looks like the answer is "no", because I didn't know about this feature.
More on . It's not said, but here again it can be simple or double quotes. So this :
"""
this is a monologue

I like talk to myself
"""
as well as this :
'''
I start to run out of idea for the example

Good thing it's the last one.
'''
 
  • Like
Reactions: User #19006

v01d_08

Member
Modder
Jan 2, 2018
233
304
Ren'py will see as a string this :
And in both the starting character can be present, as long as it's escaped :
Looks like we are talking about different things. I was writing about opening brace -> {, and you wrote about opening quote -> ".

But anyway, your remark about quotes and escaped symbols was very useful to me. Will start to fix it tomorrow.
 
  • Like
Reactions: User #19006
5.00 star(s) 4 Votes