_( )
comes in.default mc_name = "Unknown"
define mc = Character("[mc_name]")
label start:
scene black with fade
$ mc_name = renpy.input("What is your name? {i}(Press ENTER for 'Yusef'){/i}")
$ mc_name = mc_name.strip() or "Yusef"
mc "Hi, my name is [mc]."
"*** THE END ***"
return
default mc_name = "Unknown"
define mc = Character("[mc_name]", color="#4169E1", what_prefix='"', what_suffix='"')
define mct = Character("[mc_name]", color="#4169E1", what_prefix='{i}(', what_suffix='){/i}')
define c = Character("Chuck", color="#FAEBD7", what_prefix='"', what_suffix='"')
define k = Character("Kathleen", color="#9F9F9F", what_prefix='"', what_suffix='"')
label start:
scene black with fade
$ mc_name = renpy.input("What is your name? {i}(Press ENTER for 'Yusef'){/i}")
$ mc_name = mc_name.strip() or "Yusef"
mc "Hi, my name is [mc]."
mct "... and I'm thinking about [k]."
"*** THE END ***"
return
"
.My VN will have a fixed name for teh MC (its somewhat part of the story).Yup. RenPy does a pretty good job at extracting things that need to be marked for translation. However, sometimes you need to manually tell it "translate this too"... and that's where the_( )
comes in.
That said, it's kinda unusual for developers to have different default names for different translations. William tends to always be William. Daisy is always Daisy. Instead, names (except for the MC) are usually fixed.
So, much more common would be something like:
Python:default mc_name = "Unknown" define mc = Character("[mc_name]") label start: scene black with fade $ mc_name = renpy.input("What is your name? {i}(Press ENTER for 'Yusef'){/i}") $ mc_name = mc_name.strip() or "Yusef" mc "Hi, my name is [mc]." "*** THE END ***" return
Better would be something like:
Python:default mc_name = "Unknown" define mc = Character("[mc_name]", color="#4169E1", what_prefix='"', what_suffix='"') define mct = Character("[mc_name]", color="#4169E1", what_prefix='{i}(', what_suffix='){/i}') define c = Character("Chuck", color="#FAEBD7", what_prefix='"', what_suffix='"') define k = Character("Kathleen", color="#9F9F9F", what_prefix='"', what_suffix='"') label start: scene black with fade $ mc_name = renpy.input("What is your name? {i}(Press ENTER for 'Yusef'){/i}") $ mc_name = mc_name.strip() or "Yusef" mc "Hi, my name is [mc]." mct "... and I'm thinking about [k]." "*** THE END ***" return
Coding it this way means all dialogue "spoken" by the character is surrounded by double quotes. And all character "thoughts" are show in parentheses and italics (which some devs do the hard way, by adding the markup tags to each and every line of dialogue manually). It's a little extra coding for an easier life later, as well as being slightly more polished.
And yes, I'm mixing strings within double quotes and strings within single quotes. I find it easier than using escape characters for"
.
_()
thingy to make things easier for translators.define uw = Character(_("Unknown Woman"), color="#4169E1")
the string "Unknown Woman" will be detected by Ren'Py SDK as a translatable text and then these lines will appear somewhere in the translation script:translate MyLanguage strings: #MyLanguage being the translation language - Spanish, French or whatever
old = "Unknown Woman"
new = "" # <- insert your translation here
_()
symbol, that string can still be translated, but Ren'Py SDK won't extract it automatically and the translator will need to write those lines of code himself. And, as that translation function only works if the old
string matches identically the one in the original script, it's better to let the machine handle this, because if the translator writes old "Unknown woman"
instead of old "Unknown Woman"
, the translation won't be displayed.renpy.input
text too. So in 79flavors 's example, best practices would bedefault mc_name = _("Unknown")
define mc = Character("[mc_name]")
label start:
scene black with fade
$ mc_name = renpy.input(_("What is your name? {i}(Press ENTER for 'Yusef'){/i}"))
$ mc_name = mc_name.strip() or "Yusef"
mc "Hi, my name is [mc]."
"*** THE END ***"
return
default mc_name = _("Unknown")
define mc = Character("[mc_name]", color="#4169E1", what_prefix='"', what_suffix='"')
define mct = Character("[mc_name]", color="#4169E1", what_prefix='{i}(', what_suffix='){/i}')
define c = Character(_("Chuck"), color="#FAEBD7", what_prefix='"', what_suffix='"')
define k = Character(_("Kathleen"), color="#9F9F9F", what_prefix='"', what_suffix='"')
label start:
scene black with fade
$ mc_name = renpy.input(_("What is your name? {i}(Press ENTER for 'Yusef'){/i}"))
$ mc_name = mc_name.strip() or "Yusef"
mc "Hi, my name is [mc]."
mct "... and I'm thinking about [k]."
"*** THE END ***"
return
_()
symbol when defining a character as we saw above, but also when creating a textbutton
, showing some text
or tooltip
... so basically every time you write something to be displayed outside the dialog blocks and choice menus, as Ren'Py SDK won't extract those strings by default.label start:
mc "Hi, my name is [mc]" # note that it's missing a full stop.
# game/script.rpy:33
translate spanish start_657286c9: # spanish is the target language, and start_657286c9 is the encrypted hash for that line
# mc "Hi, my name is [mc]"
mc "Hola, me llamo [mc]." # that's the Spanish translation I wrote for that line, including the missing full stop.
start_657286c9
in this case) and display on screen the translated lines.label start:
mc "Hi, my name is [mc]." # nice, you fixed it!
# game/script.rpy:33
translate spanish start_539e1991: # note that now the numbers in the hash are completely different (old hash = start_657286c9)
# mc "Hi, my name is [mc]."
mc "" # When generating the translation files, this line will appear either blank or with the original text on it
label start:
mc "Hi, my name is [mc]." id start_657286c9 # now you're identifying this line with the old hash
Thanks for that explanation.8< -----snip----->8
Now, when Ren'Py reaches this line while running the translation, it will look for the old hash in the translation files instead of calculating and searching a new one. And that's great because the meaning of that line is still the same as before, so there was no real reason to force a change in the already existing translation.
As you see, it's a bit complicated as you'd need to actually take a look at the translation files in order to find the old encrypted hash. So I won't get mad if you don't do it, but it would be a very nice gesture. Basically, just keep this trick in mind in case you decide to write your own translations, as it will save you some time.
I'm sorry, but an uncaught exception occurred.
After initialization, but before game start.
Exception: Language 'english' does not have any translations.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "renpy/bootstrap.py", line 326, in bootstrap
renpy.main.main()
File "renpy/main.py", line 617, in main
run(restart)
File "renpy/main.py", line 109, in run
if not renpy.arguments.post_init():
File "renpy/arguments.py", line 304, in post_init
return commands[command]()
File "renpy/translation/extract.py", line 68, in extract_strings
extract_strings_core(language, args.destination, args.merge, args.force)
File "renpy/translation/extract.py", line 32, in extract_strings_core
raise Exception("Language %r does not have any translations." % language)
Exception: Language 'english' does not have any translations.
Windows-10-10.0.19041
Ren'Py 7.4.7.1862
Ren'Py Tutorial Game Ren'Py 7.4.7.1862
Sun Aug 8 12:33:04 2021
Yeah, obviously pics can't be "translated" in a text script. Translators will need to create another pic with the desired text and then store it in a mimic route within the tl folder (for instance, if your original button is saved asThanks for that explanation.
As it stands now my buttons have the word Yes and No part of the image file.
I am guessing this is undesirable as it would make translating it impossible.
game/images/buttons/button_yes.jpeg
, then my Spanish button should be saved as game/tl/spanish/images/buttons/button_yes.jpeg
. But you don't need to edit your script: if Ren'Py is running the translation, it will display the pic stored in the translation folder instead of the original one. Not sure what you did there. After clicking on "Generate Translations" a new screen should appear, where you can type your desired language and after that you just need to click on the new "Generate Translations" button you see now. What you type in that language box is just an identification - if you typeAlso im guessing:
View attachment 1341884
The red line generates that translation file you speak off?
Testing with the tutorial:
Im guessing i need to define the language somewhere.Code:I'm sorry, but an uncaught exception occurred. After initialization, but before game start. Exception: Language 'english' does not have any translations. -- Full Traceback ------------------------------------------------------------ Full traceback: File "renpy/bootstrap.py", line 326, in bootstrap renpy.main.main() File "renpy/main.py", line 617, in main run(restart) File "renpy/main.py", line 109, in run if not renpy.arguments.post_init(): File "renpy/arguments.py", line 304, in post_init return commands[command]() File "renpy/translation/extract.py", line 68, in extract_strings extract_strings_core(language, args.destination, args.merge, args.force) File "renpy/translation/extract.py", line 32, in extract_strings_core raise Exception("Language %r does not have any translations." % language) Exception: Language 'english' does not have any translations. Windows-10-10.0.19041 Ren'Py 7.4.7.1862 Ren'Py Tutorial Game Ren'Py 7.4.7.1862 Sun Aug 8 12:33:04 2021
yellow
, when you hit "Generate Translations" Ren'Py will just create a tl/yellow
folder with all the translation scripts (they'll be named exactly as the original scripts that contain any translatable text), translation functions in these scripts will say something like translate yellow strings:
or similar and then you'd also need to add somewhere a button or a textbutton with action Language("yellow")
in order to activate the translation, but you could write your "yellow" translation in whatever language you like. Actually, Ren'Py tutorials and documentations use the term "piglatin" for their translation's stuff to show it can work with any language, as long as you always use the same word as your language identifyer (although I never liked that word, it feels kind of derogatory to me). Anyway, what I'm trying to say is that "english" should not be the problem here.None
by Ren'Py, no matter what the actual language is. If you take a look at the Tutorial's game/tl
folder you'll see a bunch of language folders. As the tutorial was originally created in English, if there's an "english" folder is just because you have just created it and it should contain all the translation files (I've done it myself right know and everything works fine on my end). If there's no "english" folder... well, I just don't know what you did to get that exception.