renpy/doc/translating_renpy.html

414 lines
24 KiB
HTML
Raw Normal View History

2023-01-18 22:13:55 +00:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Translating Ren&#39;Py &#8212; Ren&#39;Py Documentation</title>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Changelog (Ren&#39;Py 7.x-)" href="changelog.html" />
<link rel="prev" title="Skins" href="skins.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
</head><body>
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
Ren&#39;Py Documentation</a>
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li><a href="https://www.renpy.org">Home Page</a></li>
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><ul>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels &amp; Control Flow</a></li>
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Translating Ren'Py</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
</ul>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
<li><a class="reference internal" href="#">Translating Ren'Py</a><ul>
<li><a class="reference internal" href="#translation-files">Translation Files</a></li>
<li><a class="reference internal" href="#language-specific-translations">Language-Specific Translations</a></li>
<li><a class="reference internal" href="#changing-fonts">Changing Fonts</a></li>
<li><a class="reference internal" href="#changing-the-launcher-style">Changing the Launcher Style</a></li>
<li><a class="reference internal" href="#functions">Functions</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-md-9 content">
<div class="section" id="translating-ren-py">
<span id="translating-renpy"></span><h1>Translating Ren'Py<a class="headerlink" href="#translating-ren-py" title="Permalink to this headline"> link</a></h1>
<p>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.</p>
<p>To create a new translation:</p>
<ol class="arabic simple">
<li>Open the Ren'Py launcher.</li>
<li>On the preferences page, choose &quot;Open launcher project&quot;.</li>
<li>Choose &quot;Generate Translations.&quot;</li>
<li>Enter the name of the language to translate to. This should consist of
lowercase ASCII characters and underscores, so &quot;japanese&quot;, &quot;russian&quot;,
or &quot;ancient_klingon&quot; are all valid language names.</li>
<li>Choose &quot;Generate Translations.&quot;</li>
</ol>
<p>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.</p>
<div class="section" id="translation-files">
<h2>Translation Files<a class="headerlink" href="#translation-files" title="Permalink to this headline"> link</a></h2>
<p>The translation files live in launcher/game/tl/<cite>language</cite>/. With the
exception of script.rpy, all files consist of string translations that
can be translated using the <a class="reference internal" href="translation.html#string-translations"><span class="std std-ref">string translation</span></a>
syntax. Some strings might begin with &quot;## &quot;. These are comments that
are translated, wrapped, and included in the options.rpy and gui.rpy
files.</p>
<p>The translation files are:</p>
<dl class="docutils">
<dt>common.rpy</dt>
<dd>This file contains interface messages (strings) that Ren'Py may present to the
player.</dd>
<dt>developer.rpy</dt>
<dd>This file contains strings that are only of interest to creators,
and not players.</dd>
<dt>error.rpy</dt>
<dd>This file contains strings that are displayed to the developer or player
when Ren'Py has a problem.</dd>
<dt>gui.rpy</dt>
<dd>This file contains comments that are placed into the default GUI.</dd>
<dt>launcher.rpy</dt>
<dd>This file contains strings that are displayed as part of the launcher.</dd>
<dt>obsolete.rpy</dt>
<dd>The file contains strings that are not used by modern Ren'Py.</dd>
<dt>options.rpy</dt>
<dd>This file contains strings that are used to translate the comments in
the default options.rpy file.</dd>
<dt>screens.rpy</dt>
<dd>This file contains strings that are used by the default gui, and the
comments in the default screens.rpy file.</dd>
<dt>script.rpym</dt>
<dd>The contents of this file are copied, verbatim, into script.rpy
when a new project is created.</dd>
<dt>style.rpy</dt>
<dd>This file does not exist by default, but should be created when needed.
It configures the launcher styles, and the font that is used by a
generated game.</dd>
</dl>
</div>
<div class="section" id="language-specific-translations">
<h2>Language-Specific Translations<a class="headerlink" href="#language-specific-translations" title="Permalink to this headline"> link</a></h2>
<p>There is one translation that is not a straight-up translation. The
&quot;{#language name and font}&quot; translation should be replaced with the
name of the language, optionally wrapped in a launcher font, if
non-ASCII characters are used. For example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">translate</span> <span class="n">french</span> <span class="k">strings</span><span class="p">:</span>
<span class="k">old</span> <span class="s2">&quot;{#language name and font}&quot;</span>
<span class="k">new</span> <span class="s2">&quot;{font=fonts/Roboto-Light.ttf}Français{/font}&quot;</span>
</pre></div>
</div>
<p>This is used to display the language name when the launcher is
not in that language.</p>
<p>Translations beginning with &quot;{#in language font}&quot; need to be wrapped
in the same way. For example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">translate</span> <span class="n">french</span> <span class="k">strings</span><span class="p">:</span>
<span class="k">old</span> <span class="s2">&quot;{#in language font}Start using Ren&#39;Py in [lang_name]&quot;</span>
<span class="k">new</span> <span class="s2">&quot;{font=fonts/Roboto-Light.ttf}Commencez à utiliser Ren&#39;Py en [lang_name]{/font}&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="changing-fonts">
<h2>Changing Fonts<a class="headerlink" href="#changing-fonts" title="Permalink to this headline"> link</a></h2>
<p>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:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
<span class="n">translate_font</span><span class="p">(</span><span class="s2">&quot;language&quot;</span><span class="p">,</span> <span class="s2">&quot;myfont.ttf&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Where &quot;language&quot; is the language in question (for example, &quot;japanese&quot;), and
&quot;myfont.ttf&quot; is the font that should be used (for example, &quot;MTLc3m.ttf&quot;).
The font file should be placed in the launcher/game/tl/language directory,
so it can be found by the launcher.</p>
</div>
<div class="section" id="changing-the-launcher-style">
<h2>Changing the Launcher Style<a class="headerlink" href="#changing-the-launcher-style" title="Permalink to this headline"> link</a></h2>
<p>The styles used by the launcher can be configured by setting variables
in a <code class="docutils literal notranslate"><span class="pre">translate</span> <span class="pre">python</span></code> block. The following variables are available. The
names are a bit confusing, as they reflect the English-language translation.</p>
<p>These variables are only available in the launcher.</p>
<dl class="var">
<dt id="var-gui.LIGHT_FONT">
define <code class="descname">gui.LIGHT_FONT</code> = &quot;Roboto-Light.ttf&quot;<a class="headerlink" href="#var-gui.LIGHT_FONT" title="Permalink to this definition"> link</a></dt>
<dd><p>The path to the font used for normal text in the launcher.</p>
</dd></dl>
<dl class="var">
<dt id="var-gui.REGULAR_FONT">
define <code class="descname">gui.REGULAR_FONT</code> = &quot;Roboto-Regular.ttf&quot;<a class="headerlink" href="#var-gui.REGULAR_FONT" title="Permalink to this definition"> link</a></dt>
<dd><p>The path to the font used for heavy-weight text in the launcher.</p>
</dd></dl>
<dl class="var">
<dt id="var-gui.REGULAR_BOLD">
define <code class="descname">gui.REGULAR_BOLD</code> = False<a class="headerlink" href="#var-gui.REGULAR_BOLD" title="Permalink to this definition"> link</a></dt>
<dd><p>If True, heavy-weight text is bolded.</p>
</dd></dl>
<dl class="var">
<dt id="var-gui.FONT_SCALE">
define <code class="descname">gui.FONT_SCALE</code> = 1.0<a class="headerlink" href="#var-gui.FONT_SCALE" title="Permalink to this definition"> link</a></dt>
<dd><p>A scaling factor that is applied to all text in the launcher.</p>
</dd></dl>
<p>A <code class="docutils literal notranslate"><span class="pre">translate</span> <span class="pre">python</span></code> block is used to set these variables. For example, the
following is used to change the fonts in the Arabic translation of
Ren'Py:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">translate</span> <span class="n">arabic</span> <span class="k">python</span><span class="p">:</span>
<span class="n">gui</span><span class="o">.</span><span class="n">REGULAR_FONT</span> <span class="o">=</span> <span class="s2">&quot;DejaVuSans.ttf&quot;</span>
<span class="n">gui</span><span class="o">.</span><span class="n">LIGHT_FONT</span> <span class="o">=</span> <span class="s2">&quot;DejaVuSans.ttf&quot;</span>
<span class="n">gui</span><span class="o">.</span><span class="n">FONT_SCALE</span> <span class="o">=</span> <span class="o">.</span><span class="mi">9</span>
<span class="n">gui</span><span class="o">.</span><span class="n">REGULAR_BOLD</span> <span class="o">=</span> <span class="kc">True</span>
</pre></div>
</div>
</div>
<div class="section" id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline"> link</a></h2>
<p>The following functions are used to configure translation in the launcher.
They should be called from the <code class="docutils literal notranslate"><span class="pre">init</span> <span class="pre">python</span></code> block.</p>
<dl class="function">
<dt id="translate_font">
<code class="descname">translate_font</code><span class="sig-paren">(</span><em>language</em>, <em>font</em><span class="sig-paren">)</span><a class="headerlink" href="#translate_font" title="Permalink to this definition"> link</a></dt>
<dd><p>This is used to set a font for <cite>language</cite>. 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.</p>
<dl class="docutils">
<dt><cite>font</cite></dt>
<dd>A string giving the name of the font file.</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="translate_define">
<code class="descname">translate_define</code><span class="sig-paren">(</span><em>language</em>, <em>define</em>, <em>value</em>, <em>help=None</em><span class="sig-paren">)</span><a class="headerlink" href="#translate_define" title="Permalink to this definition"> link</a></dt>
<dd><p>This is used to set a define when generating a game. For example, it can
be used to change the size of a font.</p>
<dl class="docutils">
<dt><cite>language</cite></dt>
<dd>The language involved.</dd>
<dt><cite>define</cite></dt>
<dd>The name of the define.</dd>
<dt><cite>value</cite></dt>
<dd>A string giving the value the define should be set to. (ie. &quot;10&quot;,
&quot;False&quot;, or &quot;'Font.ttf'&quot;).</dd>
<dt><cite>comment</cite></dt>
<dd>If not None, a comment that will be generated before the define. The
comment will only be generated if the define does not exist in
gui.rpy. There is no need to use &quot;## &quot;, as the comment will be
added and wrapped automatically.</dd>
</dl>
<p>For example, the following changes the size of dialogue text:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">translate_define</span><span class="p">(</span><span class="s2">&quot;martian&quot;</span><span class="p">,</span> <span class="s2">&quot;gui.text_size&quot;</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
</p>
<p>
&copy; Copyright 2012-2022, Tom Rothamel.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
</p>
</div>
</footer>
</body>
</html>