Tool Ren'Py Ren'py realtime translator Mod[v0.10]

Jul 28, 2025
90
32
update 18-08-2025
learning from other translator mod,translated lines will be stored in a cache json,
which will be a good start for Asynchronous translation,and you don't need to retranslate lines you read already.
And it seems that the delay decreased a bit,due to renpy's predict texts are translated before they are displayed.(You need to wait a while when you first time usingthe mod)
I improved the code protection as well.
Only realtimetrans.rpy is updated.
 
  • Like
Reactions: CAT0X0
Jul 28, 2025
90
32
update:20-08-2025
Key technical updates:
1. Implemented a timed multi-line translation request, triggered when new text is rendered. It's set to translate text within 1 second. So, if you don't see the translated text, click any button, and it should refresh the interface. I'm considering adding a refresh button or a true timed request. Currently, the timing relies on the Text.update function.
2. Added two hash sets to store the translated text before and after, reducing lookup time and preventing repeated translations.
3. Fluency has been significantly improved. This is because translation isn't completely real-time now. In Previous version, translation requests blocked rendering. Now, the Text object re-renders after retrieving the translated text.
Still Only realtimetrans.rpy is updated.
 
  • Like
Reactions: CAT0X0
Jul 28, 2025
90
32
update:21-08-2025
1-using config.periodic_callback ,i make the translate request a real periodic function.You can edit the time_interval in transconfig.rpy now.
2-the mod can adjust Text size now,you can edit FONT_SIZE_ADJUSTMENT_CONFIG in transconfig.rpy .The default config should only adjust the translated texts which are more than two times longer than the originals.

I am planning on fonts auto choose in next update.
 
Last edited:
  • Like
Reactions: CAT0X0
Jul 28, 2025
90
32
update:22-08-25
using Text.apply_custom_tags,i make it possible for you to choose your preferred fonts for translated text.
BUT there are still lots to do,as no font would support all unicodes,the mod should be able to apply different font styles for one text, As there are layout problems when simply applying {font=font1}{font=font2}text{\font}long text{\font},
i am trying to use Text.tokenize to make tokens for different fonts .It should be include in next update.

Today's update include transconfig.rpy which you can set the font you want to use now,and realtimetrans.rpy.
Besides,i would recommend
a great font covered most of the unicode except colored emojis.
 
Jul 28, 2025
90
32
update:27-08-2025
1. Rewrote the add function in Renpy's font_group to prioritize fonts added later. This ensures that the original developer's font is used when the translated text could be displayed.
2. Hook TextSegment.subsegment to read the font before running and add it to the font_group. This avoids issues with using fonts in text labels, and also manages text size changes in this section.
3. The default font currently added to the font_group is TRANSFONT from transconfig.rpy. You can change it to your preferred font. Also added Renpy's built-in twemoji font to support color emojis.
 
  • Like
Reactions: CAT0X0
Jul 28, 2025
90
32
update:29-08-2025
LLM translation is now available!

1. Add a new configuration file, llmtransconfig.rpy, to set your translation method. Currently, only OpenRouter and Google are supported. You'll need to enter your own OPENROUTER_API_KEY; otherwise, it won't work. Also, select the model you want to use; models with chain of thought are not currently supported. TRANSLATION_PROMPT is also included in this file; you can modify it if the default prompt isn't sufficient.

2. Add the transform_with_openrouter function to the realtimetrans.rpy file to support LLM translation. Translated text will be appended to the post data, improving model performance. Set the temperature to 0.1, as the translated text needs to be recovered by the translated HTML structure.
3. I strongly recommend editing the Time_Interval in transconfig.rpy to meet the rate limits of your LLM API provider (for OpenRouter, this should be bigger than 3 if you're using the free model).
4- This is not an advertisement for OpenRouter, I just chose the free LLM API provider for testing, the general OpenAI style API will be supported in the next update.
 
Jul 28, 2025
90
32
update:03-09-2025

1. Switching from Only OpenReuter to support all OpenAI-style API translations.
Parameters in llmtransconfig have been modified, allowing manual adjustment of parameters such as MAX_TOKENS, TIME_OUT, BASE_URL, MODEL, and APPENDED_LINES.
2. Adding a proxy switch and proxy parameters to support users who prefer using proxies.
3. Testing with some models with Chain of Thought revealed that they functioned properly under low temperature settings.
4. Detaching all translation functions from the main thread using renpy.invoke_in_thread and renpy.invoke_in_main_thread to avoid high latency in receiving responses when using LLM translation, which could block game progress. However, please note that renpy.invoke_in_main_thread does not exist in old renpy versions .
5.Added a retry mechanism; if the translated text is same to the original text, one retry will be performed.
 
Last edited:
Jul 28, 2025
90
32
Further aim is trying to make the mod work in android version renpy games and add a screen in the game start or an option in the preferences to avoid manually modify
 

Nobre

Member
Mar 12, 2022
232
181
Code:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/llmtransconfig.rpy", line 26: is not terminated with a newline. (Check strings and parenthesis.)
                            2. Preserve all HTML tags, format codes, and special marks (such as {{color=

Ren'Py Version: Ren'Py 8.3.0.24082114
Thu Sep  4 09:40:54 2025
 
Jul 28, 2025
90
32
Code:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/llmtransconfig.rpy", line 26: is not terminated with a newline. (Check strings and parenthesis.)
                            2. Preserve all HTML tags, format codes, and special marks (such as {{color=

Ren'Py Version: Ren'Py 8.3.0.24082114
Thu Sep  4 09:40:54 2025
Sorry,there is a typo in llmtransconfig.rpy line 7
API_KEY =Your-API-Key-Here"
missing a "
Here is the corrected file.
Thanks for your reply.
 

Nobre

Member
Mar 12, 2022
232
181
I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/00start.rpy", line 211, in script call
call _gl_test
File "renpy/common/00gltest.rpy", line 390, in script
$ __gl_test()
File "renpy/common/00start.rpy", line 211, in script call
call _gl_test
File "renpy/common/00gltest.rpy", line 390, in script
$ __gl_test()
File "renpy/common/00gltest.rpy", line 390, in <module>
$ __gl_test()
File "renpy/common/00gltest.rpy", line 319, in _m1_00gltest__gl_test
_gl_performance_test()
File "renpy/common/00gltest.rpy", line 342, in _gl_performance_test
ui.interact(suppress_underlay=True, suppress_overlay=True)
File "game/realtimetrans.rpy", line 121, in process_pending_translations
if current_time - LAST_TRANSLATION_TIME < time_interval:
NameError: name 'time_interval' is not defined
 
Jul 28, 2025
90
32
I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/00start.rpy", line 211, in script call
call _gl_test
File "renpy/common/00gltest.rpy", line 390, in script
$ __gl_test()
File "renpy/common/00start.rpy", line 211, in script call
call _gl_test
File "renpy/common/00gltest.rpy", line 390, in script
$ __gl_test()
File "renpy/common/00gltest.rpy", line 390, in <module>
$ __gl_test()
File "renpy/common/00gltest.rpy", line 319, in _m1_00gltest__gl_test
_gl_performance_test()
File "renpy/common/00gltest.rpy", line 342, in _gl_performance_test
ui.interact(suppress_underlay=True, suppress_overlay=True)
File "game/realtimetrans.rpy", line 121, in process_pending_translations
if current_time - LAST_TRANSLATION_TIME < time_interval:
NameError: name 'time_interval' is not defined
You should also paste other 3 files to your game dir.
https://attachments.f95zone.to/2025/08/5200736_transconfig.rpy
https://attachments.f95zone.to/2025/08/5183631_useragentlist.rpy
 
  • Like
Reactions: Nobre

reitzh

Newbie
Feb 25, 2023
22
8
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/realtimetrans.rpy", line 288: invalid syntax
context_items.append(f"Original: {original}\nTranslated: {translated}")
^

Ren'Py Version: Ren'Py 7.6.3.23091805
Thu Sep 4 19:28:58 2025



Error bro
 
Jul 28, 2025
90
32
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/realtimetrans.rpy", line 288: invalid syntax
context_items.append(f"Original: {original}\nTranslated: {translated}")
^

Ren'Py Version: Ren'Py 7.6.3.23091805
Thu Sep 4 19:28:58 2025



Error bro
It seems that f string is not supported in Python2. Ren'py 7 will be supported in next update.
 

cemo45

New Member
May 29, 2018
14
1
Hello,
Thank you very much for your work.
What else do we need to do besides copying the files you specified to the game folder?
 
Jul 28, 2025
90
32
Hello,
Thank you very much for your work.
What else do we need to do besides copying the files you specified to the game folder?
There are two files you should edit.
transconfig.rpy and llmtransconfig.rpy
realtimetrans.rpy is the key file contains all func and you should not edit it if you don't know what you are doing.
useragentlist.rpy is to hide translate request as a normal request from a browser for google translate.
And the ttf file is a really useful font covers most languages and i set it as the default font.