Page 1 of 2
Translation issue
Posted: Sun May 05, 2019 6:05 pm
by arty
Hey there!
I was trying to translate the credits screen of my game, but I'm running into an issue. The translated text doesn't show up. It just shows the original text?
My source looks like this:
Code: Select all
credits = (_('Writing, Programming'), 'arty'), (_('Editing'), ....)
credits_s = "{size=80}White Monday\n\n"
c1 = ''
for c in credits:
if not c1==c[0]:
credits_s += "\n{size=50}" + c[0] + "\n"
credits_s += "{size=30}" + c[1] + "\n"
c1=c[0]
....
image cred = Text(credits_s, text_align=0.5)
....
show cred
I cut out some parts to keep the code short.
This gets recognized by Renpy, and a translation file was generated. I filled it out like this:
Code: Select all
translate deutsch strings:
# credits.rpy:48
old "Writing, Programming"
new "Autor, Programmierung"
.....
But when I play the game, the English text shows up, no German anywhere. Does anyone know how to make this work?
Thanks!
Re: Translation issue
Posted: Sun May 05, 2019 11:50 pm
by nature1996
I think you need to use "[variable!t]" rater than variable for the text to translate, though I'm not sure. That's what I understood from the tutorial, but I kind of feel it is not that clear in it.
Re: Translation issue
Posted: Mon May 06, 2019 12:18 am
by Matalla
I'm interested in this, since in a couple of weeks I'll start the translation process for a project.
In some small tests I made, interpolated variables are translated just fine without the !t thing. Could it be because (it seems) arty's code is python and not regular renpy code?
Re: Translation issue
Posted: Mon May 06, 2019 12:32 am
by nature1996
I don't think so. The part in python is actually the translation file from ren'py, and not part of the script itself.
also, if it is not the !t part, i would guess it is because he uses the variable directly rather than using "[variable]", though it would need to be tested.
Re: Translation issue
Posted: Mon May 06, 2019 12:55 am
by Matalla
No, I was not talking about the translation block, it's the first block of code what I was thinking about (and looks like python to me, specially the part inside the for loop). But you're probably right in the issue isn't in the code being python, but the way of showing the variable, it was just the first thing I noticed, I didn't even check how it was written.
Re: Translation issue
Posted: Mon May 06, 2019 3:06 am
by arty
Where would I need to put the square brackets in my code? The values of the variables are passed around a few times before "cred" is shown (as an image, nevertheless), so I'm not sure at which point the [ ] need to go.
Re: Translation issue
Posted: Mon May 06, 2019 4:02 am
by Matalla
arty wrote: ↑Mon May 06, 2019 3:06 am
Where would I need to put the square brackets in my code? The values of the variables are passed around a few times before "cred" is shown (as an image, nevertheless), so I'm not sure at which point the [ ] need to go.
I don't think you can use brackets with the way your code works. Maybe try double underscore as suggested here
viewtopic.php?t=49205
It seems a similar problem, so maybe it works. And let us know how this work, I'm afraid I'll face a similar ordeal soon.
Re: Translation issue
Posted: Mon May 06, 2019 4:08 am
by arty
Alright, thanks for the tip. I will try it when I get home and let you know if it worked.
Re: Translation issue
Posted: Mon May 06, 2019 3:38 pm
by arty
Matalla wrote: ↑Mon May 06, 2019 4:02 am
arty wrote: ↑Mon May 06, 2019 3:06 am
Where would I need to put the square brackets in my code? The values of the variables are passed around a few times before "cred" is shown (as an image, nevertheless), so I'm not sure at which point the [ ] need to go.
I don't think you can use brackets with the way your code works. Maybe try double underscore as suggested here
viewtopic.php?t=49205
It seems a similar problem, so maybe it works. And let us know how this work, I'm afraid I'll face a similar ordeal soon.
I tried the double underscore just now, and the text still doesn't get translated, unfortunately.
Re: Translation issue
Posted: Mon May 06, 2019 3:48 pm
by nature1996
try this:
Code: Select all
c1 = ''
for c in credits:
if not c1==c[0]:
credits_s += "\n{size=50}" + "[c[0]!t]" + "\n"
credits_s += "{size=30}" + "[c[1]!t]" + "\n"
c1=c[0]
This is what I suggested before, though I don't know if it will work. Might not need the !t, but I put it there just in case. You might also need to check your translation file if you made modification to the script (like the double underscore)
Re: Translation issue
Posted: Tue May 07, 2019 4:12 pm
by arty
nature1996 wrote: ↑Mon May 06, 2019 3:48 pm
try this:
Code: Select all
c1 = ''
for c in credits:
if not c1==c[0]:
credits_s += "\n{size=50}" + "[c[0]!t]" + "\n"
credits_s += "{size=30}" + "[c[1]!t]" + "\n"
c1=c[0]
This is what I suggested before, though I don't know if it will work. Might not need the !t, but I put it there just in case. You might also need to check your translation file if you made modification to the script (like the double underscore)
That causes every line of the credits to be replaced with the last two lines, but their English version.
Re: Translation issue
Posted: Tue May 07, 2019 4:54 pm
by nature1996
I have a saying for those situation: whelp, that happened...
Jocking aside, does it show the right thing in the original language? I didn't change much, if anything at all from how the code originally worked, so I'm at at lost...
Edit: might want to try without the !t, the problem might be due to the fact it only do the replacement when the text is shown, so by that time both variable are in their final state, aka last label and name
Re: Translation issue
Posted: Tue May 07, 2019 4:58 pm
by arty
No, it doesn't show any text at all anymore in the original language if I use your method.
Re: Translation issue
Posted: Tue May 07, 2019 5:05 pm
by nature1996
I posted an edit on the previous post. Also, maybe this:
https://www.renpy.org/doc/html/text.htm ... ating-data and that:
https://www.python.org/dev/peps/pep-3101/ might help. My guess for now is that this is an exception case about the string construction. Maybe building it another way could help.
Re: Translation issue
Posted: Tue May 07, 2019 5:12 pm
by arty
Hmm, thank you for the links. I will have to look into this further.