Translation for complex structure in renpy

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
User avatar
derkonstantin
Newbie
Posts: 10
Joined: Wed Jan 25, 2017 9:30 am
Contact:

Translation for complex structure in renpy

#1 Post by derkonstantin »

Hi !.
First of all. i am sorry for my English.
In this topic viewtopic.php?f=51&t=25245 some dev gave us his code for quest log.
I look it in and see this (full code in quests.rpy)

Code: Select all

        goals.append(Goal("peter", "Find and help Peter"))
        goals.append(Goal("paul", "Find and help Paul"))
        goals.append(Goal("mary", "Find and help Mary"))
        goals.append(Goal("finish", "Return to Eileen for your reward"))

        stages.append(Stage("peter,paul,mary", "atlast"))
        stages.append(Stage("finish"))
        
        quests.append(Quest("Eileen's Quest",
            "Help Eileen out by helping out her friends Peter, Paul, and Mary who are each in different rooms.  Eileen is in the pink room.",
            "Tutorial",
            goals,
            stages)
I am trying to create some translation for this code. Renpy didn`t create any templates for this code.
So my question is: How I can translate strings in complex python structure?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Translation for complex structure in renpy

#2 Post by Ocelot »

You can use function _ to generate translations for some strings. Do not aply it to lines which do not need to be translated (like id or something like that)

Code: Select all

goals.append(Goal("peter", _("Find and help Peter")))
< < insert Rick Cook quote here > >

User avatar
derkonstantin
Newbie
Posts: 10
Joined: Wed Jan 25, 2017 9:30 am
Contact:

Re: Translation for complex structure in renpy

#3 Post by derkonstantin »

Ocelot wrote:You can use function _ to generate translations for some strings. Do not aply it to lines which do not need to be translated (like id or something like that)

Code: Select all

goals.append(Goal("peter", _("Find and help Peter")))
Thanks.

User avatar
derkonstantin
Newbie
Posts: 10
Joined: Wed Jan 25, 2017 9:30 am
Contact:

Re: Translation for complex structure in renpy

#4 Post by derkonstantin »

As I found - "_" is not enough.
Should use double - "__".

User avatar
derkonstantin
Newbie
Posts: 10
Joined: Wed Jan 25, 2017 9:30 am
Contact:

Re: Translation for complex structure in renpy

#5 Post by derkonstantin »

Hi. I am use this code in my game and have some trouble with translation for tooltip

Code: Select all

    image tooltip_inventory_dark_side_letter = LiveComposite((700, 73), (3,0), ImageReference("information"), 
                    (3,30), Text(__("Это первое, что я нашел у себя в карманах. Вы не поверите, но это - письмо!"), style="tips_bottom"))
and I have translation file

Code: Select all

    # items.rpy:58
    old "Это первое, что я нашел у себя в карманах. Вы не поверите, но это - письмо!"
    new "This was the first thing I found in my pockets. You could not believe but it's a latter!
But as I found - images in renpy create in init stage - so I see tooltip as image with untranslated text.
can I somehow fix it?
Or I need redone tooltip mech without any image?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Translation for complex structure in renpy

#6 Post by xela »

If normal translation doesn't work, ConditonSwitch might, you can condition whichever text is displayed with the language in use. I've never translated anything in Ren'Py but there is no reason for it to fail. The second sentence is horribly translated btw, both in spelling and grammar.
Like what we're doing? Support us at:
Image

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Translation for complex structure in renpy

#7 Post by PyTom »

In many places, you're going to want to use a string with the !t modifier.

For example, it can be used in the following screen code.

Code: Select all

if h < 6:
    $ period = _("night")
elif h < 12:
    $ period = _("morning")
elif h < 18:
    $ period = _("evening")

"It is the [period!t]."
Translated code will also include [period!t], which with then be replaced by one of the four string translations.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
derkonstantin
Newbie
Posts: 10
Joined: Wed Jan 25, 2017 9:30 am
Contact:

Re: Translation for complex structure in renpy

#8 Post by derkonstantin »

xela wrote:If normal translation doesn't work, ConditonSwitch might, you can condition whichever text is displayed with the language in use. I've never translated anything in Ren'Py but there is no reason for it to fail. The second sentence is horribly translated btw, both in spelling and grammar.
Thanks.
For now I create some workarounds.
ps Yes I now that my English is not so well). So thanks twice.)

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]