evennia/docs/2.x/Concepts/Internationalization.html
Evennia docbuilder action e535f5782a Updated HTML docs.
2023-10-19 20:22:27 +00:00

335 lines
No EOL
17 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Internationalization &#8212; Evennia 2.x documentation</title>
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Text Encodings" href="Text-Encodings.html" />
<link rel="prev" title="Messages varying per receiver" href="Change-Message-Per-Receiver.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<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="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Text-Encodings.html" title="Text Encodings"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Change-Message-Per-Receiver.html" title="Messages varying per receiver"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" accesskey="U">Core Concepts</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Internationalization</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Internationalization</a><ul>
<li><a class="reference internal" href="#changing-server-language">Changing server language</a></li>
<li><a class="reference internal" href="#translating-evennia">Translating Evennia</a><ul>
<li><a class="reference internal" href="#hints-on-translation">Hints on translation</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Change-Message-Per-Receiver.html"
title="previous chapter">Messages varying per receiver</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Text-Encodings.html"
title="next chapter">Text Encodings</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Concepts/Internationalization.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
<ul>
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
<li><a href="http://games.evennia.com">Game Index</a> </li>
<li>
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
<a href="https://evennia.blogspot.com/">Blog</a>
</li>
</ul>
<h3>Doc Versions</h3>
<ul>
<li><a href="Internationalization.html">2.x (main branch)</a></li>
<ul>
<li><a href="../1.3.0/index.html">1.3.0 (v1.3.0 branch)</a></li>
<li><a href="../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
</ul>
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="internationalization">
<h1>Internationalization<a class="headerlink" href="#internationalization" title="Permalink to this headline"></a></h1>
<p><em>Internationalization</em> (often abbreviated <em>i18n</em> since there are 18 characters
between the first “i” and the last “n” in that word) allows Evennias core
server to return texts in other languages than English - without anyone having
to edit the source code.</p>
<p>Language-translations are done by volunteers, so support can vary a lot
depending on when a given language was last updated. Below are all languages
(besides English) with some level of support. Generally, any language not
updated after Sept 2022 will be missing some translations.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 29%" />
<col style="width: 43%" />
<col style="width: 27%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Language Code</p></th>
<th class="head"><p>Language</p></th>
<th class="head"><p>Last updated</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>de</p></td>
<td><p>German</p></td>
<td><p>Dec 2022</p></td>
</tr>
<tr class="row-odd"><td><p>es</p></td>
<td><p>Spanish</p></td>
<td><p>Aug 2019</p></td>
</tr>
<tr class="row-even"><td><p>fr</p></td>
<td><p>French</p></td>
<td><p>Dec 2022</p></td>
</tr>
<tr class="row-odd"><td><p>it</p></td>
<td><p>Italian</p></td>
<td><p>Oct 2022</p></td>
</tr>
<tr class="row-even"><td><p>ko</p></td>
<td><p>Korean (simplified)</p></td>
<td><p>Sep 2019</p></td>
</tr>
<tr class="row-odd"><td><p>la</p></td>
<td><p>Latin</p></td>
<td><p>Feb 2021</p></td>
</tr>
<tr class="row-even"><td><p>pl</p></td>
<td><p>Polish</p></td>
<td><p>Feb 2019</p></td>
</tr>
<tr class="row-odd"><td><p>pt</p></td>
<td><p>Portugese</p></td>
<td><p>Oct 2022</p></td>
</tr>
<tr class="row-even"><td><p>ru</p></td>
<td><p>Russian</p></td>
<td><p>Apr 2020</p></td>
</tr>
<tr class="row-odd"><td><p>sv</p></td>
<td><p>Swedish</p></td>
<td><p>Sep 2022</p></td>
</tr>
<tr class="row-even"><td><p>zh</p></td>
<td><p>Chinese (simplified)</p></td>
<td><p>May 2019</p></td>
</tr>
</tbody>
</table>
<p>Language translations are found in the <a class="reference external" href="https://github.com/evennia/evennia/blob/main/evennia/locale/">evennia/locale</a>
folder. Read below if you want to help improve an existing translation of
contribute a new one.</p>
<section id="changing-server-language">
<h2>Changing server language<a class="headerlink" href="#changing-server-language" title="Permalink to this headline"></a></h2>
<p>Change language by adding the following to your <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code>
file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="n">USE_I18N</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">LANGUAGE_CODE</span> <span class="o">=</span> <span class="s1">&#39;en&#39;</span>
</pre></div>
</div>
<p>Here <code class="docutils literal notranslate"><span class="pre">'en'</span></code> (the default English) should be changed to the abbreviation for one
of the supported languages found in <code class="docutils literal notranslate"><span class="pre">locale/</span></code> (and in the list above). Restart
the server to activate i18n.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>Even for a fully translated language you will still see English text
in many places when you start Evennia. This is because we expect you (the
developer) to know English (you are reading this manual after all). So we
translate <em>hard-coded strings that the end player may see</em> - things you
cant easily change from your mygame/ folder. Outputs from Commands and
Typeclasses are generally <em>not</em> translated, nor are console/log outputs.</p>
</div>
<aside class="sidebar">
<p class="sidebar-title">Windows users</p>
<p>If you get errors concerning <code class="docutils literal notranslate"><span class="pre">gettext</span></code> or <code class="docutils literal notranslate"><span class="pre">xgettext</span></code> on Windows,
see the <a class="reference external" href="https://docs.djangoproject.com/en/4.1/topics/i18n/translation/#gettext-on-windows">Django documentation</a>.
A self-installing and up-to-date version of gettext for Windows (32/64-bit) is
available on Github as <a class="reference external" href="https://github.com/mlocati/gettext-iconv-windows">gettext-iconv-windows</a>.</p>
</aside>
</section>
<section id="translating-evennia">
<h2>Translating Evennia<a class="headerlink" href="#translating-evennia" title="Permalink to this headline"></a></h2>
<p>Translations are found in the core <code class="docutils literal notranslate"><span class="pre">evennia/</span></code> library, under
<code class="docutils literal notranslate"><span class="pre">evennia/evennia/locale/</span></code>. You must make sure to have cloned this repository
from <a class="reference external" href="https://github.com/evennia/evennia/blob/main/evennia">Evennias github</a> before you can proceed.</p>
<p>If you cannot find your language in <code class="docutils literal notranslate"><span class="pre">evennia/evennia/locale/</span></code> its because no one
has translated it yet. Alternatively you might have the language but find the
translation bad … You are welcome to help improve the situation!</p>
<p>To start a new translation you need to first have cloned the Evennia repository
with GIT and activated a python virtualenv as described on the
<a class="reference internal" href="../Setup/Installation.html"><span class="doc std std-doc">Setup Quickstart</span></a> page.</p>
<p>Go to <code class="docutils literal notranslate"><span class="pre">evennia/evennia/</span></code> - that is, not your game dir, but inside the <code class="docutils literal notranslate"><span class="pre">evennia/</span></code>
repo itself. If you see the <code class="docutils literal notranslate"><span class="pre">locale/</span></code> folder you are in the right place. Make
sure your <code class="docutils literal notranslate"><span class="pre">virtualenv</span></code> is active so the <code class="docutils literal notranslate"><span class="pre">evennia</span></code> command is available. Then run</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> evennia makemessages --locale &lt;language-code&gt;
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">&lt;language-code&gt;</span></code> is the <a class="reference external" href="http://www.science.co.il/Language/Codes.asp">two-letter locale code</a>
for the language you want to translate, like sv for Swedish or es for
Spanish. After a moment it will tell you the language has been processed. For
instance:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> evennia makemessages --locale sv
</pre></div>
</div>
<p>If you started a new language, a new folder for that language will have emerged
in the <code class="docutils literal notranslate"><span class="pre">locale/</span></code> folder. Otherwise the system will just have updated the
existing translation with eventual new strings found in the server. Running this
command will not overwrite any existing strings so you can run it as much as you
want.</p>
<p>Next head to <code class="docutils literal notranslate"><span class="pre">locale/&lt;language-code&gt;/LC_MESSAGES</span></code> and edit the <code class="docutils literal notranslate"><span class="pre">**.po</span></code> file you
find there. You can edit this with a normal text editor but it is easiest if
you use a special po-file editor from the web (search the web for “po editor”
for many free alternatives), for example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>- [gtranslator](https://wiki.gnome.org/Apps/Gtranslator)
- [poeditor](https://poeditor.com/)
</pre></div>
</div>
<p>The concept of translating is simple, its just a matter of taking the english
strings you find in the <code class="docutils literal notranslate"><span class="pre">**.po</span></code> file and add your languages translation best
you can. Once you are done, run</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>`evennia compilemessages`
</pre></div>
</div>
<p>This will compile all languages. Check your language and also check back to your
<code class="docutils literal notranslate"><span class="pre">.po</span></code> file in case the process updated it - you may need to fill in some missing
header fields and should usually note who did the translation.</p>
<p>When you are done, make sure that everyone can benefit from your translation!
Make a PR against Evennia with the updated <code class="docutils literal notranslate"><span class="pre">**.po</span></code> file. Less ideally (if git is
not your thing) you can also attach it to a new post in our forums.</p>
<section id="hints-on-translation">
<h3>Hints on translation<a class="headerlink" href="#hints-on-translation" title="Permalink to this headline"></a></h3>
<p>Many of the translation strings use <code class="docutils literal notranslate"><span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code> placeholders. This is because they
are to be used in <code class="docutils literal notranslate"><span class="pre">.format()</span></code> python operations. While you can change the
<em>order</em> of these if it makes more sense in your language, you must <em>not</em>
translate the variables in these formatting tags - Python will look for them!</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Original: &quot;|G{key} connected|n&quot;
Swedish: &quot;|G{key} anslöt|n&quot;
</pre></div>
</div>
<p>You must also retain line breaks <em>at the start and end</em> of a message, if any
(your po-editor should stop you if you dont). Try to also end with the same
sentence delimiter (if that makes sense in your language).</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Original: &quot;\n(Unsuccessfull tried &#39;{path}&#39;).&quot;
Swedish: &quot;\nMisslyckades med att nå &#39;{path}&#39;).&quot;
</pre></div>
</div>
<p>Finally, try to get a feel for who a string is for. If a special technical term
is used it may be more confusing than helpful to translate it, even if its
outside of a <code class="docutils literal notranslate"><span class="pre">{...}</span></code> tag. A mix of English and your language may be clearer
than you forcing some ad-hoc translation for a term everyone usually reads in
English anyway.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Original: &quot;\nError loading cmdset: No cmdset class &#39;{classname}&#39; in &#39;{path}&#39;.
\n(Traceback was logged {timestamp})&quot;
Swedish: &quot;Fel medan cmdset laddades: Ingen cmdset-klass med namn &#39;{classname}&#39; i {path}.
\n(Traceback loggades {timestamp})&quot;
</pre></div>
</div>
</section>
</section>
</section>
</div>
</div>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<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="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Text-Encodings.html" title="Text Encodings"
>next</a> |</li>
<li class="right" >
<a href="Change-Message-Per-Receiver.html" title="Messages varying per receiver"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" >Core Concepts</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Internationalization</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2023, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>