This file is indexed.

/usr/share/doc/renpy/html/translation.html is in renpy-doc 6.17.6-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!DOCTYPE html>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Translation &mdash; Ren&#39;Py Documentation</title>
    <link rel="stylesheet" href="_static/screen.css" type="text/css" media="screen, projection"/>
    <link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="print" />

    <!--[if lt IE 8]>
    <link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="screen, projection"/>
    <![endif]-->

    <link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '6.18.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </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>
    <link rel="top" title="Ren&#39;Py Documentation" href="index.html" />
    <link rel="next" title="Displayables" href="displayables.html" />
    <link rel="prev" title="Text" href="text.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="displayables.html" title="Displayables"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="text.html" title="Text"
             accesskey="P">previous</a> |</li>

        <li> <img src="_static/logo.png" width=19 height=21 align=center> 
        <li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
        <li><a href="index.html">Ren&#39;Py Documentation</a></li> 
      </ul>
    </div>
  <div class="container">
  <div class="span4">
    
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Translation</a><ul>
<li><a class="reference internal" href="#primary-and-alternate-languages">Primary and Alternate Languages</a></li>
<li><a class="reference internal" href="#generating-translation-files">Generating Translation Files</a></li>
<li><a class="reference internal" href="#translating-dialogue">Translating Dialogue</a><ul>
<li><a class="reference internal" href="#translation-units">Translation Units</a></li>
<li><a class="reference internal" href="#translate-statement">Translate Statement</a></li>
<li><a class="reference internal" href="#more-complex-translations">More Complex Translations</a></li>
<li><a class="reference internal" href="#tips">Tips</a></li>
</ul>
</li>
<li><a class="reference internal" href="#menu-and-string-translations">Menu and String Translations</a><ul>
<li><a class="reference internal" href="#translating-substitutions">Translating substitutions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#image-and-file-translations">Image and File Translations</a></li>
<li><a class="reference internal" href="#style-translations">Style Translations</a></li>
<li><a class="reference internal" href="#default-language">Default Language</a></li>
<li><a class="reference internal" href="#translation-actions-functions-and-variables">Translation Actions, Functions, and Variables</a></li>
<li><a class="reference internal" href="#unsanctioned-translations">Unsanctioned Translations</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="text.html"
                        title="previous chapter">Text</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="displayables.html"
                        title="next chapter">Displayables</a></p>
            <h4>Search</h4>
            
            <div id="cse-search-form" style="width: 100%;"></div>

      <div class="copydata">
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    <br>
      </div>
        </div>
      </div>
  
  </div>
  
    
    <div class="document span20 last">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="translation">
<span id="id1"></span><h1>Translation<a class="headerlink" href="#translation" title="Permalink to this headline"></a></h1>
<p>Ren'Py contains a comprehensive framework for the translation of
visual novels. There are four main types of things that can be
translated:</p>
<dl class="docutils">
<dt>Dialogue</dt>
<dd>The main dialogue of the script can be translated, including a
provision for splitting, combining, omitting, and reordering
lines.</dd>
<dt>Menus and Interface Strings</dt>
<dd>All interface text can be translated.</dd>
<dt>Images and Files</dt>
<dd>It's possible to include variant images and other files that are
used when a language is selected.</dd>
<dt>Styles</dt>
<dd>It's possible to customize styles based on the language, so that
the game can automatically switch to a font appropriate for the
language that was chosen.</dd>
</dl>
<p>Ren'Py's translation support is currently focused on sanctioned
translations, where the game's creators either release the game
scripts to the translator or create translation templates
themselves. Support for unsanctioned translations is more limited.</p>
<div class="section" id="primary-and-alternate-languages">
<h2>Primary and Alternate Languages<a class="headerlink" href="#primary-and-alternate-languages" title="Permalink to this headline"></a></h2>
<p>Ren'Py expects each game to be written in a single primary
language. This is called the <tt class="docutils literal"><span class="pre">None</span></tt> language, regardless of what
language it actually is. (For example, if the game was written in
English, English will be the <tt class="docutils literal"><span class="pre">None</span></tt> language.)</p>
<p>When the None language is selected, most of Ren'Py's translation
functionality is disabled.</p>
<p>Alternate languages are referred to by names which can double as
python identifiers. (Starts with a letter or underscore, followed by
letters, numbers, and underscores.)</p>
</div>
<div class="section" id="generating-translation-files">
<h2>Generating Translation Files<a class="headerlink" href="#generating-translation-files" title="Permalink to this headline"></a></h2>
<p>When the project scripts are available, translation files can be
generated by opening the project in the Ren'Py Launcher, and choosing
&quot;Generate Translations&quot;. The launcher will prompt you for the name of
the language to generate, and will then proceed to create or update
the translation files.</p>
<p>The translation files live in directories underneath the &quot;tl&quot;
subdirectory of the game directory. For example, if you create a
piglatin translation of the tutorial project, translation files will
be placed under <tt class="docutils literal"><span class="pre">tutorial/game/tl/piglatin</span></tt>.</p>
<p>There will be one translation file created per game script file. The
common.rpy file will also be created to contain translations of
strings found in the common code.</p>
</div>
<div class="section" id="translating-dialogue">
<h2>Translating Dialogue<a class="headerlink" href="#translating-dialogue" title="Permalink to this headline"></a></h2>
<p>As Ren'Py is a visual novel engine, we expect most translation to
involve dialogue. Ren'Py includes a flexible framework that allows
dialogue to be split, combined, reordered, and omitted entirely.</p>
<div class="section" id="translation-units">
<h3>Translation Units<a class="headerlink" href="#translation-units" title="Permalink to this headline"></a></h3>
<p>The fundamental unit of translation is a block of zero or more
translatable statements, optionally followed by a single say
statement. Translatable statements are the voice and nvl statements. For example
take the following game:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">label</span> <span class="n">start</span><span class="p">:</span>
    <span class="n">e</span> <span class="s">&quot;Thank you for taking a look at the Ren&#39;Py translation framework.&quot;</span>

    <span class="k">show</span> <span class="n">eileen</span> <span class="n">happy</span>

    <span class="n">e</span> <span class="s">&quot;We aim to provide a comprehensive framework for translating dialogue, strings, images, and styles.&quot;</span>

    <span class="n">e</span> <span class="s">&quot;Pretty much everything your game needs!&quot;</span>
</pre></div>
</div>
<p>This is broken up into multiple translation units. Each unit has an
identifier assigned to it, with the identifier being generated from
the label preceding the unit, and the code inside the unit. (If
multiple units would be assigned the same translation number, a serial
number to the second and later units to distinguish them.)</p>
<p>In the example above, the first unit generated is assigned the identifier
start_636ae3f5, and contains the statement:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">e</span> <span class="s">&quot;Thank you for taking a look at the Ren&#39;Py translation framework.&quot;</span>
</pre></div>
</div>
<p>The second unit is given the identifier start_bd1ad9e1m and contains:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">e</span> <span class="s">&quot;We aim to provide a comprehensive framework for translating dialogue, strings, images, and styles.&quot;</span>
</pre></div>
</div>
<p>The third unit has the identifier start_9e949aac, and contains:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">e</span> <span class="s">&quot;Pretty much everything your game needs!&quot;</span>
</pre></div>
</div>
<p>These units are created automatically by Ren'Py when the game script
is loaded.</p>
</div>
<div class="section" id="translate-statement">
<h3>Translate Statement<a class="headerlink" href="#translate-statement" title="Permalink to this headline"></a></h3>
<p>When you generate translations for a language, Ren'Py will generate a
translate statement corresponding to each translation unit. When
translating the code above, Ren'Py will generate:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="c"># game/script.rpy:95</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_636ae3f5</span><span class="p">:</span>

    <span class="c"># e &quot;Thank you for taking a look at the Ren&#39;Py translation framework.&quot;</span>
    <span class="n">e</span> <span class="s">&quot;&quot;</span>

<span class="c"># game/script.rpy:99</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_bd1ad9e1</span><span class="p">:</span>

    <span class="c"># e &quot;We aim to provide a comprehensive framework for translating dialogue, strings, images, and styles.&quot;</span>
    <span class="n">e</span> <span class="s">&quot;&quot;</span>

<span class="c"># game/script.rpy:101</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_9e949aac</span><span class="p">:</span>

    <span class="c"># e &quot;Pretty much everything your game needs!&quot;</span>
    <span class="n">e</span> <span class="s">&quot;&quot;</span>
</pre></div>
</div>
<p>This can be translated by editing the generated code. A finished
translation might look like:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="c"># game/script.rpy:95</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_636ae3f5</span><span class="p">:</span>
    <span class="c"># e &quot;Thank you for taking a look at the Ren&#39;Py translation framework.&quot;</span>
    <span class="n">e</span> <span class="s">&quot;Ankthay ouyay orfay akingtay away ooklay atway ethay En&#39;Pyray anslationtray ameworkfray.&quot;</span>

<span class="c"># game/script.rpy:99</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_bd1ad9e1</span><span class="p">:</span>

    <span class="c"># e &quot;We aim to provide a comprehensive framework for translating dialogue, strings, images, and styles.&quot;</span>
    <span class="n">e</span> <span class="s">&quot;Eway aimway otay ovidepray away omprehensivecay ameworkfray orfay anslatingtray ialogueday, ingsstray, imagesway, andway ylesstay.&quot;</span>

<span class="c"># game/script.rpy:101</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_9e949aac</span><span class="p">:</span>

    <span class="c"># e &quot;Pretty much everything your game needs!&quot;</span>
    <span class="n">e</span> <span class="s">&quot;Ettypray uchmay everythingway ouryay amegay eedsnay!&quot;</span>
</pre></div>
</div>
<p>When a block in the main script is encountered, Ren'Py checks to see
if a translate statement corresponding to that block exists. If so, it
executes the translate statement instead of the translated block,
showing the user the translation.</p>
</div>
<div class="section" id="more-complex-translations">
<h3>More Complex Translations<a class="headerlink" href="#more-complex-translations" title="Permalink to this headline"></a></h3>
<p>Translate statements do not need to contain 1-to-1 translations of the
original language. For example, a long line could be split:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="c"># game/script.rpy:99</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_bd1ad9e1</span><span class="p">:</span>
    <span class="c"># e &quot;We aim to provide a comprehensive framework for translating dialogue, strings, images, and styles.&quot;</span>
    <span class="n">e</span> <span class="s">&quot;Eway aimway otay ovidepray away omprehensivecay ameworkfray...&quot;</span>
    <span class="n">e</span> <span class="s">&quot;...orfay anslatingtray ialogueday, ingsstray, imagesway, andway ylesstay.&quot;</span>
</pre></div>
</div>
<p>Or a statement can be removed, by replacing it with the pass statement:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="c"># game/script.rpy:101</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_9e949aac</span><span class="p">:</span>

     <span class="c"># e &quot;Pretty much everything your game needs!&quot;</span>
     <span class="k">pass</span>
</pre></div>
</div>
<p>It's also possible to run non-dialogue statements, such as
conditionals or python code. For example, we can translate:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">e</span> <span class="s">&quot;You scored [points] points!&quot;</span>
</pre></div>
</div>
<p>into:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="c"># game/script.rpy:103</span>
<span class="k">translate</span> <span class="n">piglatin</span> <span class="n">start_36562aba</span><span class="p">:</span>

    <span class="c"># e &quot;You scored [points] points!&quot;</span>
    <span class="n">e</span> <span class="k">$</span> <span class="n">latin_points</span> <span class="o">=</span> <span class="n">to_roman_numerals</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
    <span class="n">e</span> <span class="s">&quot;Ouyay oredscay [latin_points] ointspay!&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="tips">
<h3>Tips<a class="headerlink" href="#tips" title="Permalink to this headline"></a></h3>
<p>Be very careful when changing dialogue that has been translated,
especially when that dialogue is repeated in more than one place
inside a label. In some cases, it may be necessary to assign
a translation identifier directly, using a statement like:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="bp">None</span> <span class="n">mylable_03ac197e_1</span><span class="p">:</span>
    <span class="s">&quot;...&quot;</span>
</pre></div>
</div>
<p>Adding labels can also confuse the translation process. To prevent
this, labels that are given the hide clause are ignored by the
translation code.:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">label</span> <span class="n">ignored_by_translation</span> <span class="k">hide</span><span class="p">:</span>
    <span class="s">&quot;...&quot;</span>
</pre></div>
</div>
<p>While translation blocks may include python code, this code should not
have side effects visible outside of the block. That's because
changing languages will restart the translation block, causing the
side effects to occur multiple times.</p>
</div>
</div>
<div class="section" id="menu-and-string-translations">
<h2>Menu and String Translations<a class="headerlink" href="#menu-and-string-translations" title="Permalink to this headline"></a></h2>
<p>In addition to dialogue, Ren'Py is able to translate text found in
menus and other strings. Interface translations are a 1-to-1
substitution. Wherever a string is found, it will be replaced by a
single replacement.</p>
<p>When generating translations, Ren'Py will scan the script files for
menus, and for strings enclosed inside the _() function. It will then
place the strings inside a translate strings block. For example, if we
have the following script:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">define</span> <span class="n">e</span> <span class="o">=</span> <span class="n">Character</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s">&quot;Eileen&quot;</span><span class="p">))</span>

<span class="c"># ...</span>

<span class="k">menu</span><span class="p">:</span>

     <span class="s">&quot;Go West&quot;</span><span class="p">:</span>
        <span class="c"># ...</span>

     <span class="s">&quot;Head East&quot;</span><span class="p">:</span>
        <span class="c"># ...</span>
</pre></div>
</div>
<p>Ren'Py will generate the following code:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="n">piglatin</span> <span class="n">strings</span><span class="p">:</span>

    <span class="n">old</span> <span class="s">&quot;Eileen&quot;</span>
    <span class="n">new</span> <span class="s">&quot;&quot;</span>

    <span class="n">old</span> <span class="s">&quot;Go West&quot;</span>
    <span class="n">new</span> <span class="s">&quot;&quot;</span>

    <span class="n">old</span> <span class="s">&quot;Head East&quot;</span>
    <span class="n">new</span> <span class="s">&quot;&quot;</span>
</pre></div>
</div>
<p>Which can then be translated:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="n">piglatin</span> <span class="n">strings</span><span class="p">:</span>

    <span class="n">old</span> <span class="s">&quot;Eileen&quot;</span>
    <span class="n">new</span> <span class="s">&quot;Eileenway&quot;</span>

    <span class="n">old</span> <span class="s">&quot;Go West&quot;</span>
    <span class="n">new</span> <span class="s">&quot;Ogay Estway&quot;</span>

    <span class="n">old</span> <span class="s">&quot;Head East&quot;</span>
    <span class="n">new</span> <span class="s">&quot;Eadhay Eastway&quot;</span>
</pre></div>
</div>
<p>String translations are also applied to dialogue strings that are not
translated as dialogue.</p>
<p>When the same string is used in multiple places in the code, the string can
be distinguished using the {#...} text tag. Even though they display the
same, Ren'Py considers all of these distinct strings for the purpose
of translation:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="s">&quot;New&quot;</span>
<span class="s">&quot;New{#project}&quot;</span>
<span class="s">&quot;New{#game}&quot;</span>
<span class="s">&quot;New{#playlist}&quot;</span>
</pre></div>
</div>
<p>The translate strings statement can also be used to translate the None
language. This can be used to when the game is written in a non-English
language, to translate the Ren'Py user interface.</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="bp">None</span> <span class="n">strings</span><span class="p">:</span>
     <span class="n">old</span> <span class="s">&quot;Start Game&quot;</span>
     <span class="n">new</span> <span class="s">&quot;Artstay Amegay&quot;</span>
</pre></div>
</div>
<div class="section" id="translating-substitutions">
<h3>Translating substitutions<a class="headerlink" href="#translating-substitutions" title="Permalink to this headline"></a></h3>
<p>String substitutions can be translated using the !t conversion
flag. So the following code will be translatable using the dialogue
and code translation systems:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">if</span> <span class="n">mood_points</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">:</span>
    <span class="k">$</span> <span class="n">mood</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s">&quot;great&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="k">$</span> <span class="n">mood</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s">&quot;awful&quot;</span><span class="p">)</span>

<span class="s">&quot;I&#39;m feeling [mood!t].&quot;</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="image-and-file-translations">
<h2>Image and File Translations<a class="headerlink" href="#image-and-file-translations" title="Permalink to this headline"></a></h2>
<p>When translating a game, it may be necessary to replace a file
with a translate version. For example, if an image contains text, it
might make sense to replace it with a version of the image where the
text is in another language.</p>
<p>Ren'Py handles this by looking in the translation directory for the
image. For example, if the &quot;piglatin&quot; language is in use, and
&quot;library.png&quot; is loaded, Ren'Py will use &quot;game/tl/piglatin/library.png&quot;
in preference to &quot;game/library.png&quot;.</p>
</div>
<div class="section" id="style-translations">
<h2>Style Translations<a class="headerlink" href="#style-translations" title="Permalink to this headline"></a></h2>
<p>It may be necessary to change styles - especially font-related
styles - when translating a game. Ren'Py handles this with translate
style blocks and translate python blocks. These blocks can contain code
to change language-related variables and styles. For example:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="n">piglatin</span> <span class="k">style</span> <span class="na">default</span><span class="p">:</span>
    <span class="na">font</span> <span class="s">&quot;stonecutter.ttf&quot;</span>
</pre></div>
</div>
<p>or equivalently:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">translate</span> <span class="n">piglatin</span> <span class="k">python</span><span class="p">:</span>
    <span class="k">style</span><span class="o">.</span><span class="na">default</span><span class="o">.</span><span class="na">font</span> <span class="o">=</span> <span class="s">&quot;stonecutter.ttf&quot;</span>
</pre></div>
</div>
<p>When a language is activated - either at the start of the game, or
after a language change - Ren'Py resets the styles to their contents
at the end of the init phase. It then runs all translate python blocks
and translate style blocks associated with the current language, guaranteeing
that blocks appearing earlier in a file are executed first. Finally, it
rebuilds styles, allowing the changes to take effect.</p>
<p>Style translations may be added to any .rpy file.</p>
</div>
<div class="section" id="default-language">
<h2>Default Language<a class="headerlink" href="#default-language" title="Permalink to this headline"></a></h2>
<p>The default language is chosen using the following method:</p>
<ul class="simple">
<li>If the RENPY_LANGUAGE environment variable is set, that language is
used.</li>
<li>If <a class="reference internal" href="config.html#var-config.language"><tt class="xref std std-var docutils literal"><span class="pre">config.language</span></tt></a> is set, that language is used.</li>
<li>If the game has ever chosen a language in the past, that language is
used.</li>
<li>If this is the first time the game has been run,
<a class="reference internal" href="config.html#var-config.default_language"><tt class="xref std std-var docutils literal"><span class="pre">config.default_language</span></tt></a> is used. (This defaults to the None
language.)</li>
<li>Otherwise, the None language is used.</li>
</ul>
</div>
<div class="section" id="translation-actions-functions-and-variables">
<h2>Translation Actions, Functions, and Variables<a class="headerlink" href="#translation-actions-functions-and-variables" title="Permalink to this headline"></a></h2>
<p>The main way to switch languages is with the Language action.</p>
<dl class="function">
<dt id="Language">
<tt class="descname">Language</tt><big>(</big><em>language</em><big>)</big><a class="headerlink" href="#Language" title="Permalink to this definition"></a></dt>
<dd><p>Changes the language of the game to <cite>language</cite>.</p>
<dl class="docutils">
<dt><cite>language</cite></dt>
<dd>A string giving the language to translate to, or None to use
the default language of the game script.</dd>
</dl>
</dd></dl>

<p>The Language action can be used to add a language preference to the
preferences screen, using code like:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">frame</span><span class="p">:</span>
    <span class="na">style_group</span> <span class="s">&quot;pref&quot;</span>
    <span class="k">has</span> <span class="k">vbox</span>

    <span class="k">label</span> <span class="n">_</span><span class="p">(</span><span class="s">&quot;Language&quot;</span><span class="p">)</span>
    <span class="k">textbutton</span> <span class="s">&quot;English&quot;</span> <span class="na">action</span> <span class="n">Language</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>
    <span class="k">textbutton</span> <span class="s">&quot;Igpay Atinlay&quot;</span> <span class="na">action</span> <span class="n">Language</span><span class="p">(</span><span class="s">&quot;piglatin&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>There are two translation-related functions:</p>
<dl class="function">
<dt id="renpy.change_language">
<tt class="descclassname">renpy.</tt><tt class="descname">change_language</tt><big>(</big><em>language</em><big>)</big><a class="headerlink" href="#renpy.change_language" title="Permalink to this definition"></a></dt>
<dd><p>Changes the current language to <cite>language</cite>, which can be a string or
None to use the default language.</p>
</dd></dl>

<dl class="function">
<dt id="renpy.known_languages">
<tt class="descclassname">renpy.</tt><tt class="descname">known_languages</tt><big>(</big><big>)</big><a class="headerlink" href="#renpy.known_languages" title="Permalink to this definition"></a></dt>
<dd><p>Returns the set of known languages. This does not include the default
language, None.</p>
</dd></dl>

<p>In addition, there are two functions that are related to string
translation:</p>
<dl class="function">
<dt id="_">
<tt class="descname">_</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#_" title="Permalink to this definition"></a></dt>
<dd><p>(Single underscore) Returns <cite>s</cite> unchanged. Ren'Py will scan for
strings enclosed in this function, and add them to the list of
translatable strings. The strings will not be translated until
they are displayed.</p>
</dd></dl>

<dl class="function">
<dt id="__">
<tt class="descname">__</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#__" title="Permalink to this definition"></a></dt>
<dd><p>(Double underscore) Returns <cite>s</cite> immediately translated into the
current language. Strings enclosed in this function will be added
to the list of translatable strings. Note that the string may be
double-translated, if it matches a string translation when it
is displayed.</p>
</dd></dl>

<p>There are two language-related variables. One is
<a class="reference internal" href="config.html#var-config.language"><tt class="xref std std-var docutils literal"><span class="pre">config.language</span></tt></a>, which is used to change the default language
of the game.</p>
<dl class="var">
<dt id="var-_preferences.language">
<tt class="descname">_preferences.language</tt><a class="headerlink" href="#var-_preferences.language" title="Permalink to this definition"></a></dt>
<dd><p>The name of the current language, or None if the default language is
being used. This should be treated as a read-only variable. To
change the language, call <a class="reference internal" href="#renpy.change_language" title="renpy.change_language"><tt class="xref py py-func docutils literal"><span class="pre">renpy.change_language()</span></tt></a>.</p>
</dd></dl>

</div>
<div class="section" id="unsanctioned-translations">
<h2>Unsanctioned Translations<a class="headerlink" href="#unsanctioned-translations" title="Permalink to this headline"></a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">It's best to ask a game's creators for permission before
creating an unsanctioned translation.</p>
</div>
<p>Ren'Py includes a small amount of support for creating translations
without the active assistance of the game's creators. This support
consists of the ability to automatically create a string translation
file from all of the strings in the game. Since string translations
are used for untranslated dialogue, this technique makes it possible
to translate a game.</p>
<p>To create a string translation file, perform the following steps:</p>
<ul class="simple">
<li>Set the RENPY_LANGUAGE environment variable to the language you want
to translate to.</li>
<li>Set the RENPY_UPDATE_STRINGS environment variable to a non-empty
value.</li>
<li>Play through the game until all text is seen.</li>
</ul>
<p>This will update the &quot;game/tl/language/strings.rpy&quot; file with a
translation template that contains all of the strings in it.</p>
<p>If a game doesn't include support for changing the language, it may be
appropriate to use an init python block to set <a class="reference internal" href="config.html#var-config.language"><tt class="xref std std-var docutils literal"><span class="pre">config.language</span></tt></a>
to the target language.</p>
<p>Along with the use of string translations for dialogue, unsanctioned
translators may be interested in using the techniques described above
to translate images and styles.</p>
</div>
</div>


          </div>
        </div>
      </div>
    </div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="displayables.html" title="Displayables"
             >next</a> |</li>
        <li class="right" >
          <a href="text.html" title="Text"
             >previous</a> |</li>

        <li> <img src="_static/logo.png" width=19 height=21 align=center> 
        <li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
        <li><a href="index.html">Ren&#39;Py Documentation</a></li> 
      </ul>
    </div>



  </body>
</html>