Ren'Py Translate text _()%()

birdybubbles

New Member
May 12, 2023
5
0
hi, could you tell me how to make renpy understand that he should only translate the first part of this:

text _("number: (%s / %s)")%(bla,bla)

what renpy shows me is this, but it doesn't execute it

Old "number: (%s / %s)"
new "numero: (%s / %s)"
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
I think you want:

text _("number: ({var1} / {var2})").format(var1=num1, var2=num2)

-or-

text _("number: ({} / {})").format(num1, num2)

I'm unable to test this right now, but it's likely some variation on that theme.
See: , and maybe for hints about how things are working.

My only hesitation is the same thing that caused you the initial problem... the translation using _().
Being unable to run RenPy right now means I'm guessing rather than giving a definite answer.


Alternative note for other people in the future...

If it's just dialogue as part of the script, then it would be something like:

mc "number: ([num1] / [num2])"

Where mc is a character's id, num1 and num2 are variables.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,975
16,230
I'm unable to test this right now, but it's likely some variation on that theme.
I was able to test, and it doesn't works. Whatever if it's the old substitution style or the modern format one, in both case it doesn't works.

The solution is to totally split, not just the string, but the statement itself:
Python:
hbox:
    text _( "number: " )
    text "({} / {})".format(bla,bla)
 
  • Like
Reactions: 79flavors

moskyx

Forum Fanatic
Jun 17, 2019
4,225
13,986
Assuming he's not coding the game, just translating it, the first option should always be trying to use a double underscore __ instead of only one _ , and see what happens.

text __("number: (%s / %s)")%(bla,bla)

In case it actually works, please note that, for the translation to work on everyone's copy, the original script must always include that double underscore.

On a side note, I fucking hate 'pro' coders who use python functions instead of simple renpy language.