It is possible to translate Ren'Py itself. A complete translation translates the GUI, various Ren'Py messages, new projects, and the launcher. This should cover most gameplay and development scenarios. Right now, not every error message can be translated.
To create a new translation:
The same procedure can be used to update a language translation. To access the created translation, return to the preferences, then choose the newly created language. Note that by default, the translation will be a copy of the English translation.
The translation files live in launcher/game/tl/language/. With the exception of script.rpy, all files consist of string translations that can be translated using the string translation syntax. Some strings might begin with "## ". These are comments that are translated, wrapped, and included in the options.rpy and gui.rpy files.
The translation files are:
There is one translation that is not a straight-up translation. The "{#language name and font}" translation should be replaced with the name of the language, optionally wrapped in a launcher font, if non-ASCII characters are used. For example:
translate french strings:
old "{#language name and font}"
new "{font=fonts/Roboto-Light.ttf}Français{/font}"
This is used to display the language name when the launcher is not in that language.
Translations beginning with "{#in language font}" need to be wrapped in the same way. For example:
translate french strings:
old "{#in language font}Start using Ren'Py in [lang_name]"
new "{font=fonts/Roboto-Light.ttf}Commencez à utiliser Ren'Py en [lang_name]{/font}"
Ren'Py ships with a default font (DejaVuSans) that covers most western languages, but other fonts are often needed. A font can be configured by editing launcher/game/tl/language/style.rpy, and adding:
init python:
translate_font("language", "myfont.ttf")
Where "language" is the language in question (for example, "japanese"), and "myfont.ttf" is the font that should be used (for example, "MTLc3m.ttf"). The font file should be placed in the launcher/game/tl/language directory, so it can be found by the launcher.
The styles used by the launcher can be configured by setting variables
in a translate python
block. The following variables are available. The
names are a bit confusing, as they reflect the English-language translation.
These variables are only available in the launcher.
gui.LIGHT_FONT
= "Roboto-Light.ttf" linkThe path to the font used for normal text in the launcher.
gui.REGULAR_FONT
= "Roboto-Regular.ttf" linkThe path to the font used for heavy-weight text in the launcher.
gui.REGULAR_BOLD
= False linkIf True, heavy-weight text is bolded.
gui.FONT_SCALE
= 1.0 linkA scaling factor that is applied to all text in the launcher.
A translate python
block is used to set these variables. For example, the
following is used to change the fonts in the Arabic translation of
Ren'Py:
translate arabic python:
gui.REGULAR_FONT = "DejaVuSans.ttf"
gui.LIGHT_FONT = "DejaVuSans.ttf"
gui.FONT_SCALE = .9
gui.REGULAR_BOLD = True
The following functions are used to configure translation in the launcher.
They should be called from the init python
block.
translate_font
(language, font) linkThis is used to set a font for language. The font is used in the launcher, and also used to in games generated in that language. The font file should be placed in game/fonts.
translate_define
(language, define, value, help=None) linkThis is used to set a define when generating a game. For example, it can be used to change the size of a font.
For example, the following changes the size of dialogue text:
translate_define("martian", "gui.text_size", 12)