Create and Fuck your AI Slut -70% OFF
x

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

trans1

Newbie
Jan 24, 2023
25
0
124
Ok, game with Ren'Py 7.3.5.606 is running again, thanks.

I also noticed that if there is a $ character in the text, the following text is not translated.
I removed the line r'\$.*?(?=\n|$)' from PROTECT_PATTERNS. After that it worked.
However, I don't know whether the $ character is used for other things in Renpy.
 
Jul 28, 2025
160
55
28
Ok, game with Ren'Py 7.3.5.606 is running again, thanks.

I also noticed that if there is a $ character in the text, the following text is not translated.
I removed the line r'\$.*?(?=\n|$)' from PROTECT_PATTERNS. After that it worked.
However, I don't know whether the $ character is used for other things in Renpy.
Developers can use $ as the start of a python code line in menu.
 

trans1

Newbie
Jan 24, 2023
25
0
124
In v0.18, there are now lines that are not being translated again. The log shows the following:

Error in text to comhtml conversion: expected string or bytes-like object
Traceback (most recent call last):
File "C:\Prog\Games\ChasingSunsets-1.10-pc\renpy\exports.py", line 3766, in run
fn(*args, **kwargs)
File "game/realtimetrans.rpy", line 189, in process_translation_results
translated = html_unescape(translated)
File "game/realtimetrans.rpy", line 629, in html_unescape
text = re.sub(r'&#(\d+);', lambda m: chr(int(m.group(1))), text)
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/re.py", line 210, in sub
TypeError: expected string or bytes-like object

In v0.17, the lines are translated.
 
Jul 28, 2025
160
55
28
v0.19
update:29-09-2025
updated file:realtimetrans.rpy
Fix bugs v0.18 caused.

Error in text to comhtml conversion: expected string or bytes-like object
Traceback (most recent call last):
File "C:\Prog\Games\ChasingSunsets-1.10-pc\renpy\exports.py", line 3766, in run
fn(*args, **kwargs)
File "game/realtimetrans.rpy", line 189, in process_translation_results
translated = html_unescape(translated)
File "game/realtimetrans.rpy", line 629, in html_unescape
text = re.sub(r'&#(\d+);', lambda m: chr(int(m.group(1))), text)
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/re.py", line 210, in sub
TypeError: expected string or bytes-like object
 

trans1

Newbie
Jan 24, 2023
25
0
124
What bothers me is that if something has been translated incorrectly, for example with names: "Bill" becomes "Rechnung", I would like to change this immediately in translation_cache.json.
But this is not possible while the game is running.
Would it be possible to switch off the writing of the translation_cache with a key combination or button and switch it on again after the change?
Then you don't always have to quit, change and restart the game.
 

pepplez

Active Member
Jun 7, 2020
984
1,322
287
What bothers me is that if something has been translated incorrectly, for example with names: "Bill" becomes "Rechnung", I would like to change this immediately in translation_cache.json.
But this is not possible while the game is running.
Would it be possible to switch off the writing of the translation_cache with a key combination or button and switch it on again after the change?
Then you don't always have to quit, change and restart the game.
It would probably be easier if the translator script checked whether it was a name (game characters whose names should not be translated) or text to be translated.
 
Jul 28, 2025
160
55
28
It would probably be easier if the translator script checked whether it was a name (game characters whose names should not be translated) or text to be translated.
It is translation api 's job for nlp.
If the mod itself needs to do that,
We will finally apply local llm .
I think llm api translation is here for you if you need better translation quality.
 
Jul 28, 2025
160
55
28
What bothers me is that if something has been translated incorrectly, for example with names: "Bill" becomes "Rechnung", I would like to change this immediately in translation_cache.json.
But this is not possible while the game is running.
Would it be possible to switch off the writing of the translation_cache with a key combination or button and switch it on again after the change?
Then you don't always have to quit, change and restart the game.
Translation cachec.json is only read once in the init of game.
And written everytime save_translate_cache function was called.
I think i can change the Enable_Translation toggle button action,
when it switches to False,save_translate_cache is called
and when it switches to True, translation cache should read.json again.
 

trans1

Newbie
Jan 24, 2023
25
0
124
Somehow, it's not working quite as I had imagined.
Only after I inserted the following in “def toggle_translation():” did it work as intended:


def toggle_translation():
global DISPLAY_TRANSLATION
DISPLAY_TRANSLATION = not DISPLAY_TRANSLATION
#trans1 begin
if DISPLAY_TRANSLATION:
load_translation_cache()
else:
save_translation_cache()
#trans1 end
renpy.call_in_new_context("_force_redraw")
return
 

pepplez

Active Member
Jun 7, 2020
984
1,322
287
DISPLAY_TRANSLATION = not DISPLAY_TRANSLATION
Nice toggle, didn't know this works too.
If that worked you could shorten the other line too:

#trans1 begin
load_translation_cache() if DISPLAY_TRANSLATION else save_translation_cache()
#trans1 end
 
Jul 28, 2025
160
55
28
Somehow, it's not working quite as I had imagined.
Only after I inserted the following in “def toggle_translation():” did it work as intended:


def toggle_translation():
global DISPLAY_TRANSLATION
DISPLAY_TRANSLATION = not DISPLAY_TRANSLATION
#trans1 begin
if DISPLAY_TRANSLATION:
load_translation_cache()
else:
save_translation_cache()
#trans1 end
renpy.call_in_new_context("_force_redraw")
return
I have to warn that DISPLAY_TRANSLATION only controls the translation display,
your code will not stop translation_cache written to .json file.
In def save_translation_cache(),only if
ENABLE_TRANSLATION is set to False can stop that.
Renpy could predict dialogues, translation_cache may increase and be written to .json file,
which will invalidate your changes in the .json file.
So if you want to use your code ,it is more appropriate to stay on the current dialogue.
 
Jul 28, 2025
160
55
28
v0.20.b
update:03-10-2025
updated files:realtimetrans.rpy transconfig.rpy
1-
#trans1 begin
if DISPLAY_TRANSLATION:
load_translation_cache()
else:
save_translation_cache()
#trans1 end
trans1's code applied

2- def save_translation_cache() judgment condition is changed to avoid the changes in the .json file being overwritten
 

trans1

Newbie
Jan 24, 2023
25
0
124
I've been testing the editing feature for a while now, and it works well as long as you don't go back in the game.
Then the changed part gets overwritten again. This also happens when you exit the game and restart it.
The unedited dialogues still need to be saved somewhere.

This line:

if current_size - LAST_SAVED_CACHE_SIZE >= 1: #trans1 5:

in “def save_translation_cache():” I changed it so that the cache is immediately written to the file with each new dialog.
 

trans1

Newbie
Jan 24, 2023
25
0
124
The translation is not displayed if {bt=3} {/bt} is included in the dialog.
However, it is translated, see:
"\"{bt=3}Step-brotherrr{/bt}...I'm making sandwiches!\"": "\"{bt=3}Stiefbruder{/bt}...ich mache Sandwiches!\"",

The log shows:
Error in token replacement <store.BounceText object at 0x0000000054cbf430>
Error in token replacement <store.BounceText object at 0x0000000053fcb520>
Error in token replacement <store.BounceText object at 0x0000000054c2abe0>
Error in token replacement <store.BounceText object at 0x0000000054c723d0>
 
Jul 28, 2025
160
55
28
The translation is not displayed if {bt=3} {/bt} is included in the dialog.
However, it is translated, see:
"\"{bt=3}Step-brotherrr{/bt}...I'm making sandwiches!\"": "\"{bt=3}Stiefbruder{/bt}...ich mache Sandwiches!\"",

The log shows:
Error in token replacement <store.BounceText object at 0x0000000054cbf430>
Error in token replacement <store.BounceText object at 0x0000000053fcb520>
Error in token replacement <store.BounceText object at 0x0000000054c2abe0>
Error in token replacement <store.BounceText object at 0x0000000054c723d0>
Like ScaredText ,the objects are displayed through multi Text objects which is not supported.

I am working on using free online ocr api for these kind of problems.