The text in the dictionary is not translated (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
K_strum
Newbie
Posts: 12
Joined: Thu Oct 12, 2023 6:11 am
Contact:

The text in the dictionary is not translated (Solved)

#1 Post by K_strum »

Hello.
I have the following problem. The text from the dictionary is not translated. I have the following code:

Code: Select all

define items_db = {
    'sigarett': {
        'name': _("Цигарка"),
        'mind': _('Зменшує стрес на 30%'),
        'mind2': _('Можливо трохи зменшить стрес.'),
        'desk': _("Пом'ята й стара. Здається, її ще можна використати."),
        'desk2': _("Від одної думки про те що це опинеться у роті нудить."),
        'image': "images/items/sigarett_simple.png",
        },
        }
And this is a translation that, in theory, should work, but doesn't. Instead of a translation, you get an untranslated text.

Code: Select all

translate english strings:

    # game/script/item.rpy:2
    old "Цигарка"
    new "Cigarette"

    # game/script/item.rpy:2
    old "Зменшує стрес на 30%"
    new "Reduces stress by 30%"

    # game/script/item.rpy:2
    old "Можливо трохи зменшить стрес."
    new "Might reduce stress slightly."

    # game/script/item.rpy:2
    old "Пом'ята й стара. Здається, її ще можна використати."
    new "Old and crumpled. Looks like it still can be used."

    # game/script/item.rpy:2
    old "Від одної думки про те що це опинеться у роті нудить."
    new "Just a thought about putting it in the mouth is sickening."
The only way I have now is to create a separate dictionary for another language, but I would like to find a more convenient option.
Last edited by K_strum on Sun Jan 07, 2024 4:30 am, edited 1 time in total.

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

Re: The text in the dictionary is not translated

#2 Post by Ocelot »

How do you display your text?
It should be something like: text items_db['sigarett']['name'] or similar. If you are using text interpolation, you need to mark interpolated data as needing translation:

Code: Select all

$ item_name = items_db['sigarett']['name']
text "Name: [item_name!t]" # Notice the !t here.
< < insert Rick Cook quote here > >

K_strum
Newbie
Posts: 12
Joined: Thu Oct 12, 2023 6:11 am
Contact:

Re: The text in the dictionary is not translated

#3 Post by K_strum »

Ocelot wrote: Sat Jan 06, 2024 2:07 pm How do you display your text?
It should be something like: text items_db['sigarett']['name'] or similar. If you are using text interpolation, you need to mark interpolated data as needing translation:

Code: Select all

$ item_name = items_db['sigarett']['name']
text "Name: [item_name!t]" # Notice the !t here.
That's exactly how I use it. Thank you, it worked!

Post Reply

Who is online

Users browsing this forum: No registered users