shorter translate strings patch for renpy 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
simple_human
Newbie
Posts: 3
Joined: Thu Jan 11, 2024 4:16 pm
Contact:

shorter translate strings patch for renpy game

#1 Post by simple_human »

Hey, everybody!
Is it possible to make a translate strings patch shorter?

I know that with this patch:

Code: Select all

#patch.rpy
translate eng strings:
    old "old text"
    new "new text"
it is possible to change lines.

I want to know if this patch can be done something like this:

Code: Select all

#patch.rpy
translate eng strings:
     "old text", "new text"
I just don't want "old..." and "new..." to take up two lines in the patch, but to be in one line.
I just don't know if this is possible and how to write it correctly.
Last edited by simple_human on Thu Apr 18, 2024 6:00 pm, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: shorter translate strings patch ?

#2 Post by m_from_space »

simple_human wrote: Thu Apr 18, 2024 7:40 am Is it possible to make a translate strings patch shorter?
What do you mean by "patch"? Am I missing something?

You present string translations. They have to be in the format you showed, using a newline, not a comma.

What are you hoping to gain when making your translation file less readable by putting it in one line?

simple_human
Newbie
Posts: 3
Joined: Thu Jan 11, 2024 4:16 pm
Contact:

Re: shorter translate strings patch ?

#3 Post by simple_human »

m_from_space wrote: Thu Apr 18, 2024 9:32 am You present string translations. They have to be in the format you showed, using a newline, not a comma.
What are you hoping to gain when making your translation file less readable by putting it in one line?
The comma means nothing in this case. This is just an example to make it clear what I want to do, to have everything in one line.
something like this text = text.replace("old text", "new text").
That's why I'm asking if it's possible.

I don't have any coding knowledge, I just know where the characters dialogue lines are and few patches that I found:

Code: Select all

init python:
    def replace_text(t):
        t = t.replace("old text", "new text")
        t = t.replace("old text", "new text")
        return t
    config.say_menu_text_filter = replace_text
and

Code: Select all

translate eng strings:
    old "old text"
    new "new text"
Why do I want it on one line?
Because I don't want to stretch the patch over 8,000 lines, but only 4,000 lines.

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: shorter translate strings patch ?

#4 Post by m_from_space »

simple_human wrote: Thu Apr 18, 2024 11:26 am I don't have any coding knowledge, I just know where the characters dialogue lines are and few patches that I found:

Code: Select all

init python:
    def replace_text(t):
        t = t.replace("old text", "new text")
        t = t.replace("old text", "new text")
        return t
    config.say_menu_text_filter = replace_text
and

Code: Select all

translate eng strings:
    old "old text"
    new "new text"
Why do I want it on one line?
Because I don't want to stretch the patch over 8,000 lines, but only 4,000 lines.
The config.say_menu_text_filter has nothing to do with string translations (as part of the translation files). I don't know what exactly you are think it does. It's a function that replaces certain text elements with other text, but this happens before any translation is applied.

Just because something is 4000 lines doesn't mean it uses more memory. A newline character uses as much memory as a comma for example. The format of the translation file is for your own convenience, to make it readable.

I still don't get what you mean by "patch". This word usually refers to some program update.

Maybe you should start from the beginning and tell me what exactly you are working on right now.

simple_human
Newbie
Posts: 3
Joined: Thu Jan 11, 2024 4:16 pm
Contact:

Re: shorter translate strings patch ?

#5 Post by simple_human »

m_from_space wrote: Thu Apr 18, 2024 3:07 pm I still don't get what you mean by "patch". This word usually refers to some program update.
Not necessarily, some people call "translation patch" or "translation mod" for renpy games. You just create a file with the extension .rpy and write the code in it.
For example:

patch.rpy

Code: Select all

init python:
    def replace_text(t):
        t = t.replace("The original dialogue line of the game's character", "Translated dialogue line of the game's character")
        t = t.replace("second dialogue line of the game's character", "Translated second dialogue line of the game's character")
        t = t.replace("third dialogue line of the game's character", "Translated third dialogue line of the game's character")
        #and so on
        return t
    config.say_menu_text_filter = replace_text
drop the patch/mod file into the game folder. And during the game, that line will be translated.

I want to try a different form of patch/mod, translate eng strings

Code: Select all

translate eng strings:
    old "The original dialogue line of the game's character"
    new "Translated dialogue line of the game's character"
    
    old "second line of the game's character"
    new "Translated second dialogue line of the game's character"
    
    old "third  line of the game's character"
    new "Translated third dialogue line of the game's character"
    
    #and so on
    
but I don't like that this uses two patch/mod lines to change one line of dialogue. And if there are, let's say, 2000 lines of dialogue in the game, then in this patch/mod, there will be 4000 lines.
I want to know if it's possible to make this patch/mod work something like this:

Code: Select all

translate eng strings:

#It's just an example, to give you an idea of what I want, don't look for accuracy in it

    old "The original dialogue line of the game's character" new "Translated line of the game's character" 
    old "second dialogue line of the game's character" new "Translated second line of the game's character" 
    old "third dialogue line of the game's character" new "Translated third line of the game's character" 
    #and so on

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: shorter translate strings patch ?

#6 Post by m_from_space »

simple_human wrote: Thu Apr 18, 2024 5:59 pm Not necessarily, some people call "translation patch" or "translation mod" for renpy games. You just create a file with the extension .rpy and write the code in it.
Alright, I now get what you are talking about. Actually modding a game, by inserting a .rpy file and therefore make Renpy execute this with the rest of the game. Got you.

But as I said earlier, the translation files have nothing to do with text-filtering. You cannot just change the format of the translation files' contents. Renpy expects it to be in the format provided. If you remove the newline and insert a comma or a space, Renpy will throw an error on loading the file.

I can only repeat myself stating that there is no difference if a file contains 4000 lines without a newline or 8000 lines with a newline, since "lines" is just something a human sees. A computer only sees a newline character when reading it. It's not faster loading it when you remove that newline character and use another one instead.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]