2020-04-07 23:13:24 +02:00
|
|
|
# Internationalization
|
|
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
*Internationalization* (often abbreviated *i18n* since there are 18 characters
|
|
|
|
|
between the first "i" and the last "n" in that word) allows Evennia's core
|
|
|
|
|
server to return texts in other languages than English - without anyone having
|
|
|
|
|
to edit the source code. Take a look at the `locale` directory of the Evennia
|
|
|
|
|
installation, there you will find which languages are currently supported.
|
2020-04-07 23:13:24 +02:00
|
|
|
|
|
|
|
|
## Changing server language
|
|
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
Change language by adding the following to your `mygame/server/conf/settings.py`
|
|
|
|
|
file:
|
2020-04-07 23:13:24 +02:00
|
|
|
|
|
|
|
|
```python
|
2021-05-26 21:55:05 +02:00
|
|
|
|
2020-04-07 23:13:24 +02:00
|
|
|
USE_I18N = True
|
|
|
|
|
LANGUAGE_CODE = 'en'
|
2021-05-26 21:55:05 +02:00
|
|
|
|
2020-04-07 23:13:24 +02:00
|
|
|
```
|
|
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
Here `'en'` should be changed to the abbreviation for one of the supported
|
|
|
|
|
languages found in `locale/`. Restart the server to activate i18n. The
|
|
|
|
|
two-character international language codes are found
|
|
|
|
|
[here](http://www.science.co.il/Language/Codes.asp).
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
> Windows Note: If you get errors concerning `gettext` or `xgettext` on Windows,
|
|
|
|
|
> see the
|
|
|
|
|
> [Django documentation](https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#gettext-on-windows).
|
|
|
|
|
> A self-installing and up-to-date version of gettext for Windows (32/64-bit) is
|
|
|
|
|
> available on [Github](https://github.com/mlocati/gettext-iconv-windows).
|
2020-04-07 23:13:24 +02:00
|
|
|
|
|
|
|
|
## Translating Evennia
|
|
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
```important::
|
|
|
|
|
|
|
|
|
|
Evennia offers translations of hard-coded strings in the server, things like
|
|
|
|
|
"Connection closed" or "Server restarted", strings that end users will see and
|
|
|
|
|
which game devs are not supposed to change on their own. Text you see in the log
|
|
|
|
|
file or on the command line (like error messages) are generally *not* translated
|
|
|
|
|
(this is a part of Python).
|
|
|
|
|
|
|
|
|
|
In addition, text in default Commands and in default Typeclasses will *not* be
|
|
|
|
|
translated by switching *i18n* language. To translate Commands and Typeclass
|
|
|
|
|
hooks you must overload them in your game directory and translate their returns
|
|
|
|
|
to the language you want. This is because from Evennia's perspective, adding
|
|
|
|
|
*i18n* code to commands tend to add complexity to code that is *meant* to be
|
|
|
|
|
changed anyway. One of the goals of Evennia is to keep the user-changeable code
|
|
|
|
|
as clean and easy- to-read as possible.
|
|
|
|
|
```
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-29 00:48:34 +02:00
|
|
|
Translations are found in the core `evennia/` library, under
|
|
|
|
|
`evennia/evennia/locale/`. You must make sure to have cloned this repository
|
|
|
|
|
from [Evennia's github](github:evennia) before you can proceed.
|
|
|
|
|
|
|
|
|
|
If you cannot find your language in `evennia/evennia/locale/` it's because noone has
|
2021-05-26 21:55:05 +02:00
|
|
|
translated it yet. Alternatively you might have the language but find the
|
|
|
|
|
translation bad ... You are welcome to help improve the situation!
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
To start a new translation you need to first have cloned the Evennia repositry
|
|
|
|
|
with GIT and activated a python virtualenv as described on the [Setup
|
|
|
|
|
Quickstart](../Setup/Setup-Quickstart) page.
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-29 00:48:34 +02:00
|
|
|
Go to `evennia/evennia/` - that is, not your game dir, but inside the `evennia/`
|
|
|
|
|
repo itself. If you see the `locale/` folder you are in the right place. Make
|
|
|
|
|
sure your `virtualenv` is active so the `evennia` command is available. Then run
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
evennia makemessages --locale <language-code>
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2020-06-16 16:53:35 +02:00
|
|
|
where `<language-code>` is the [two-letter locale code](http://www.science.co.il/Language/Codes.asp)
|
2021-05-26 21:55:05 +02:00
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
evennia makemessages --locale sv
|
|
|
|
|
|
|
|
|
|
If you started a new language, a new folder for that language will have emerged
|
|
|
|
|
in the `locale/` 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.
|
|
|
|
|
|
|
|
|
|
Next head to `locale/<language-code>/LC_MESSAGES` and edit the `**.po` 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).
|
|
|
|
|
|
|
|
|
|
The concept of translating is simple, it's just a matter of taking the english
|
|
|
|
|
strings you find in the `**.po` file and add your language's translation best
|
|
|
|
|
you can. The `**.po` format (and many supporting editors) allow you to mark
|
|
|
|
|
translations as "fuzzy". This tells the system (and future translators) that you
|
|
|
|
|
are unsure about the translation, or that you couldn't find a translation that
|
|
|
|
|
exactly matched the intention of the original text. Other translators will see
|
|
|
|
|
this and might be able to improve it later. Finally, you need to compile your
|
|
|
|
|
translation into a more efficient form. Do so from the `evennia` folder again:
|
2020-04-07 23:13:24 +02:00
|
|
|
|
|
|
|
|
evennia compilemessages
|
|
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
This will go through all languages and create/update compiled files (`**.mo`)
|
|
|
|
|
for them. This needs to be done whenever a `**.po` file is updated.
|
2020-04-07 23:13:24 +02:00
|
|
|
|
2021-05-26 21:55:05 +02:00
|
|
|
When you are done, make sure that everyone can benefit from your translation!
|
|
|
|
|
Make a PR against Evennia with the updated `**.po` and `*.mo` files. Less
|
|
|
|
|
ideally (if git is not your thing) you can also attach them to a new post in our
|
|
|
|
|
forums.
|