Techlog #4. Tip. Renpy Translations and templates [en]
Added 2023-08-02 23:11:43 +0000 UTC
A very small note on translations and translations is more complicated.
Relatively recently, there was a proposal to translate the game into some other languages besides English and Russian, so I seriously thought: If translating just dialogues does not cause any difficulties, then what about the texts that are in variables? How can I bring them together?
As it turns out, . It does not lie on the surface, it was necessary to google a little. In general, I will give a simple example.
If you write a double underline to the text, when generating translations through RenPy, it will go into the translations folder and you can easily set translations for this! The main thing is not to do it inside class fields. RenPy will understand nothing in this case.
But what about more difficult cases? For example with template strings like the following:
That is, here, instead of {} - the necessary text should be substituted. I came up with the following solution:
I have a method inside a character class that increments one or another parameter. It has two options. The characteristic itself, I have it in the form of Enum, as well as format - the text that I want to insert into these brackets. As you can see, all this falls into another function - system_notify.
That is, if I set the format parameter, then it will substitute these values through format into this string with brackets, * in front of the variable - this is something of the rest of the operator. That is, it will decompose all the values from the sheet there. Otherwise - if there is no format parameter - it will simply substitute the text into the standard notification function from renpy.
Here is a mini tutorial.