Translate text inside an object [solved]

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
xavimat
Eileen-Class Veteran
Posts: 1460
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Translate text inside an object [solved]

#1 Post by xavimat »

I have info text inside objects. It's a map with regions that, in a screen, show the info when hovered.
Something like this:

Code: Select all

init python:
    class Region:
        def __init__(self, name, info):
            self.name = name
            self.info = info
label start:
    $ region = Region("Village", "I was born in this village... Oh, nostalgia...")
    call screen map
    return
screen map():
    textbutton region.name:
        tooltip region.info
        action Return(region)
    $ tooltip = GetTooltip()
    if tooltip:
        text tooltip align (.5, .5)
My question is, how can I translate this?
I'm making my game in two languages; the translation framework in Renpy works great for dialogue and strings in screens, but I don't know where to start to translate this strings inside objects. Can I use the Renpy translation framework? Should I create a specific function that checks _preferences.language and returns the correct string?
Last edited by xavimat on Sat Apr 14, 2018 1:27 pm, edited 1 time in total.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Translate text inside an object

#2 Post by Donmai »

If the single underscore _() doesn't work, try the double underscore. I tried your code with the double underscore and it apparently worked.
https://www.renpy.org/doc/html/translat ... -variables

Code: Select all

    $ region = Region(__("Village"), __("I was born in this village... Oh, nostalgia..."))
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1460
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Translate text inside an object

#3 Post by xavimat »

Thanks, it works perfectly with the double underscore __("")
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]