Translation of scrolling credits

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
UsagiToxic
Newbie
Posts: 4
Joined: Sun Feb 18, 2018 8:56 am
Contact:

Translation of scrolling credits

#1 Post by UsagiToxic »

Hello,

I've been having trouble with the code based on this one: viewtopic.php?f=51&t=22481

Whole game has two languages which can be freely switched on the fly, but the credits for some reasons cannot be translated and always show the English ones. So far no standard Ren'Py options worked, neither did workarounds listed in this thread: viewtopic.php?f=8&t=47159. I am unable to assign two different credits to show up for different languages as well: one always overrides the other.

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

Re: Translation of scrolling credits

#2 Post by Ocelot »

None of the creits strings in your first example are marked as translateable, so it is expected. TO make strings eligible for translation in first place you need to define them using underscore function: _('some text')
< < insert Rick Cook quote here > >

UsagiToxic
Newbie
Posts: 4
Joined: Sun Feb 18, 2018 8:56 am
Contact:

Re: Translation of scrolling credits

#3 Post by UsagiToxic »

Ocelot wrote: Sun Feb 18, 2018 12:56 pm None of the creits strings in your first example are marked as translateable, so it is expected. TO make strings eligible for translation in first place you need to define them using underscore function: _('some text')
UsagiToxic wrote: Sun Feb 18, 2018 9:10 am So far no standard Ren'Py options worked, neither did workarounds listed in this thread: viewtopic.php?f=8&t=47159.
I have already tried to define them as _('some text'), __ ('some text'), (_('some text')), and who knows how else. No defining worked so far, ren'py simply ignores that.

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

Re: Translation of scrolling credits

#4 Post by Ocelot »

Show, how exactly you doing that. WOrks perfectly for me, so there is somethng wrong in how you are doing it.
< < insert Rick Cook quote here > >

UsagiToxic
Newbie
Posts: 4
Joined: Sun Feb 18, 2018 8:56 am
Contact:

Re: Translation of scrolling credits

#5 Post by UsagiToxic »

Code: Select all

credits = _('title', 'author')
This returns: TypeError: _() takes exactly 1 argument (2 given)

Code: Select all

credits = __('title', 'author')
This makes text appear as two first letters following each other. Same with:

Code: Select all

credits = __ ('title', 'author')

Code: Select all

credits = __ (_('title'), _('author'))

Code: Select all

credits = _(_('title', 'author'))
and such.

Code: Select all

credits_s = _("{size=80}Credits\n\n")
This doesn't do anything.

Code: Select all

credits_s = _('{size=80}Credits\n\n')
This doesn't do anything either. I've tried many things other than that, and yet it still looks like this at best when it doesn't crash:
MWSnap 2018-02-19, 00_20_53.jpg
If you have it perfectly working, I would love to see how and what should I do.

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

Re: Translation of scrolling credits

#6 Post by Ocelot »

By "show, how exactly you doing that", I meant, show some code which I could run, test and see problems.

Anyway, a few points:
1) Translatable strings should be defined at init time. Easiest way to do this is to use define statement:
define authors = (_('title'), _('author'))

2) Combining strings for showing, on the other hand, should be done immideately before showing credits (preferably in screen itself). Do not store them by creating whole text in init time! Otherwise even if you change language, it will not change already rendered text.

3) Do a clean restart every time when testing, do not load game. Sometimes string are saved with the game and translation would not affect them later.
< < insert Rick Cook quote here > >

UsagiToxic
Newbie
Posts: 4
Joined: Sun Feb 18, 2018 8:56 am
Contact:

Re: Translation of scrolling credits

#7 Post by UsagiToxic »

Ocelot wrote: Sun Feb 18, 2018 5:56 pm
Anyway, a few points:
1) Translatable strings should be defined at init time. Easiest way to do this is to use define statement:
define authors = (_('title'), _('author'))

2) Combining strings for showing, on the other hand, should be done immideately before showing credits (preferably in screen itself). Do not store them by creating whole text in init time! Otherwise even if you change language, it will not change already rendered text.
I doubt I can redefine credits. I have very little understanding of ren'py and the code isn't mine (I am authorized to make a translation, though), plus in the original cookbook code everything is in init python.

If there is no way to make these credits translatable, then I should probably notify the author.

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

Re: Translation of scrolling credits

#8 Post by Ocelot »

in the original cookbook code everything is in init python
Cookbook recipe was made before translations existed at all.

The reason that you need to mark strings as translatable is simple: not every string is text to be translated: you don't want to translate names of labels to jump to or path to file to open. Some things can be done automatically (like text in menus ore character dialogue), because it is obvious where you would use it. In general Python code it is impossible, because you can literally do anything with those strings. So RenPy defers to hints from developer for those.

The combining strings problem is completely different. RenPy handles translations by creating objects, which returns one or other sequence of symbols, depending on selected language. You can imagine actor which can recite a poem in different languages. So, when in US, he spokes English, in France — French, etc. By using that string in your code, you are asking actor to recite a poem and write it on paper. So, if you ask actor in US, you will get text written in English. If then you move to Germany, even though actor will recite poem in German now, text on your paper will still be in English!
This is why using strings and saving result causes problems if original strings were to change.

So, to translate credits, you need to remake them to be translateable in the first place.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Ocelot