Translation question

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
HansBr
Newbie
Posts: 9
Joined: Tue Mar 06, 2018 5:10 pm
Deviantart: HansBr
Contact:

Translation question

#1 Post by HansBr »

Hello,
I write my game in German, because it is easier for me to translate than to be creative in a foreign language. For the most part translation works well. Now I got a little problem. I have some passages where text needs to be inserted in an other string. Something like this:

Code: Select all

	$ insert = getText(1)
	a "german [insert] german"
in the translation file that would look like:

Code: Select all

# a "german [insert] german"
a "english [insert] english"
getText(x) reads constant text from something like

Code: Select all

python:
	CONST = { 1:_("abc"), 2:_("def")}
	def getText(i):
		return CONST[i]
There is a bit more to it, but that should be enough to showcase the translation part. I do not change the text string in any way in getText().

Of course there is a appropriate translation file with

Code: Select all

	old "abc"
	new "uvw"
	
	old "def"
	new "xyz"
But when I run the translated version of the game, the resulting string is:

"english abc english" It should be "english uvw english"

What am I doing wrong?

HansBr
Newbie
Posts: 9
Joined: Tue Mar 06, 2018 5:10 pm
Deviantart: HansBr
Contact:

Re: Translation question

#2 Post by HansBr »

Found it. I need to add !t to insert. It is [insert!t].
Sorry for not searching enough before asking.

HansBr
Newbie
Posts: 9
Joined: Tue Mar 06, 2018 5:10 pm
Deviantart: HansBr
Contact:

Re: Translation question

#3 Post by HansBr »

Me again.
It does not work for more complex translations.

Code: Select all

    a = someFunction(__("german {0} german {1} german").format(subst1, subst2))
still always substitutes the German parts. Double underscores do not help. !t gives the following error:

Code: Select all

   ValueError: Unlnown conversion specifier t
the exact code in this case is deep within a python block:

Code: Select all

                          menulist.append((__("Du könntest {0} mit {1} verschönern").
                                            format(target,itemName),
                                         (hooklist[h], itm["item"])))
A explicit renpy.translate() function would be nice, but I can not find anything like that. Am I missing something?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Translation question

#4 Post by Remix »

renpy.substitute() is likely what you are after...

Code: Select all

menulist.append(_("Du könntest {0} mit {1} verschönern").format(
    renpy.substitute(target),
    renpy.substitute(itemName)), ...
Would/should pre-translate the target and itemName before pyFormatting them into the _() wrapped translation string
Frameworks & Scriptlets:

HansBr
Newbie
Posts: 9
Joined: Tue Mar 06, 2018 5:10 pm
Deviantart: HansBr
Contact:

Re: Translation question

#5 Post by HansBr »

Thank you.
renpy.substitute() was exactly the function I was looking for.

lemmatree
Newbie
Posts: 3
Joined: Sat Mar 24, 2018 12:51 am
Contact:

Re: Translation question

#6 Post by lemmatree »

I would try with the suggestion as well. I am planning to do the Chinese translation.
An Amateur Gamer & A Professional Mandarin Translator. :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Alex