Translating OctoPrint

Starting with version 1.2.0 OctoPrint is ready for being translated into various languages. In order to contribute a translation you have to create a shareable language pack. In any case please always make sure of the following points:

  • Keep whitespace like in the source, e.g. newlines
  • Keep/use HTML tags like in the source, e.g. <strong>...</strong>
  • Keep placeholders like %(...)d, %(...)s etc intact (just move them where they belong to in your target language, their names should hopefully be self explanatory -- if not please ask!)
  • Since OctoPrint is mostly targeted at the hobby segment of users, use the informal version of your language (if it distinguishes between formal and informal for "you" etc) for now. I'll keep looking into if it's somehow possible to distinguish between a formal and an informal version of the language, but until I find a way to do this, OctoPrint will pretend to be the buddy of its users -- just think of how IKEA does it :wink:
  • The application name "OctoPrint" is also a translatable string in order to allow you to migrate it into a different writing system (e.g. cyrillic, katakana...). Please make sure it stays recognizable nevertheless, e.g. leave it as is unless you absolutely have to adjust it to your writing system.

Translating

Translating online

OctoPrint uses Transifex for allowing easy translations via a web frontend. If you want to add a new or improve on an existing language within OctoPrint and don't yet have an account, please sign up for a Transifex account first. After that, navigate to OctoPrint's project page on Transifex. There you can either request the addition of a new language or -- by clicking on an existing one -- request to be added to that language's translation team. After your request has been accepted you'll be able to contribute translations :slight_smile:

Translating locally

You can also contribute to OctoPrint's translations locally. You should be comfortable with editing gettext PO files for that, since this is what OctoPrint uses. There exist various editors for comfortably editing these files (e.g. Poedit), but you may also just use your preferred text editor.

The instructions on how to get everything up and running for that depend on whether you want to start translating based on an existing OctoPi setup or need to do a custom setup (e.g. on your desktop computer) first.

  • OctoPi: Log into your OctoPi installation via SSH and do the following

    ~/scripts/add-octoprint-checkout
    sudo service octoprint stop
    source ~/oprint/bin/activate
    cd ~/OctoPrint
    pip install -e .[develop]
    

    This will stop the server, create a local checkout and make sure that all changes you do to your checkout folder (e.g. pulling in
    translations from Transifex or adding yourself through copying over the .po files) will become available
    without having to run python setup.py install everytime.

  • Custom: Start off by cloning OctoPrint and changing into the directory:

    git clone https://github.com/OctoPrint/OctoPrint.git
    cd OctoPrint
    virtualenv venv
    source venv/bin/activate
    pip install -e .[develop]
    

The PO template file resides under translations/messages.pot, each language's PO file can be found under translations/<language code>/LC_MESSAGES/messages.po. Before starting on a translation you should always make sure that the PO template file is up to date and the PO files are updated accordingly, so always do a git pull first, then make sure the resources are really up to date. OctoPrint's setup.py script includes a couple of custom commands to help here. Using

python setup.py babel_refresh

you can perform a fresh extraction of all translatable strings from OctoPrint's source and update all PO files. From there you can edit your language's translation. If it's not yet available, you can create it via

python setup.py babel_new --locale=<locale>

You might want to check from time to time that everything looks fine. To do that, compile the translation into their MO and JS equivalents and "bundle" them with OctoPrint:

python setup.py babel_compile
python setup.py babel_bundle --locale=<locale>

Then startup OctoPrint (octoprint serve) and take a look at your translation results. To request a specific locale to display the UI in, you may append the query parameter l10n with the desired locale to OctoPrint's URL, e.g.

http://localhost:5000/?l10n=de

Alternatively you can select that locale in OctoPrint's "Appearance" settings or your user's Usersettings.

Transifex integration for local installations

You should take a look at the Transifex client which integrates wonderfully with a fresh OctoPrint git checkout. You can install it via pip:

pip install transifex-client

After that all tx commands should work (see tx --help or the online help for how to use it).

Retrieving translations

To pull the current translation of the locale you wish to translate, do

tx pull -l <locale>

Uploading translations

Edit your translation files either in your favourite text editor or with something like Poedit. Check if everything looks good (see below on how). If yes, push your changes:

tx push -l <locale>

Checking your translation

If you have made changes to the translation files, you should check how everything looks. First get everything ready as you would for translating locally, like described above.

Pull the translations you want to test, either by using the Transifex client (if you did the translation via its web interface) or by manually copying the po file to translations/<language code>/LC_MESSAGES/messages.po.

Then do the following:

python setup.py babel_compile
python setup.py babel_bundle --locale=<language code>

This will compile the translation files and copy them to the correct folder in OctoPrint so that they will become bundled on your copy and you don't have to continuously import language packs. You'll need to repeat these steps every time you change something in the .po file/pull from Transifex.

Restart the server (custom install: octoprint serve, OctoPi: sudo service octoprint restart). To request a specific locale to display the UI in, you may append the query parameter l10n with the desired locale to OctoPrint's URL, e.g.

http://localhost:5000/?l10n=de

You should also be able to select your locale under User Settings > Appearance and under Settings > Appearance. Note that it will NOT show up under the list of installed language packs -- you didn't install it as a language pack, you bundled it with your local OctoPrint installation.

Creating a language pack

Once you are satisfied with your translation result, create a shareable language pack. To do that, please run the following command (make sure to use the correct python version, so activate any virtual envs, e.g. source ~/oprint/bin/activate on OctoPi, or use the full path to python, e.g. ~/oprint/bin/python on OctoPi):

python setup.py babel_pack --locale=<locale>

This will create a ZIP file for you called OctoPrint-i18n-<locale>-<timestamp>.zip in the translations folder which can be installed by other OctoPrint users. A translation repository similar to the plugin repository will soon be made available to share these language packs, for now it is suggested to upload the file somewhere and either add it to the list below (this is a wiki post, if you've been an active enough member on this forum you should be able to edit it) or add the link in a comment to this topic.

:point_up: Please Note

No further languages will be accepted for inclusion into OctoPrint's core sources. The reason for that is that only such language packs should get shipped right with OctoPrint whose correctness can actually be verified and which can also be maintained by the active maintainers (read: primarily me). That is currently only possible for English and German. You are however welcome to contribute additional languages through language packs maintained by yourself.

Available language packs

The following language packs are maintained by the community and should in no way be considered official.

2 Likes

Am I the only one unable to get the procedure for updating the language to OctoPrint (after translating some more lines) by pulling from Transifex?
I followed the guide but get several errors in installing the client, and after apparently succeeding I haven't been able to download and install the updated language.
Any help?

I have the same problem with transifex-client. You can download po file manually from transifiex and put it to translation folder and make language pack.

Hi Krzysztof, thanks for the reply, I tried that but apparently something went wrong, because the menu in OctoPrint was somehow weird, would scroll up to a certain point and was messed up in the different sections, and I experienced several disconnection (and print failures!) after installing the language.
It all was solved when I reflashed the sd card and left default english language.
Pity that I cannot get this to work, I guess I'll have to stick to default language.

OctoPrint-i18n-zh_CN_20210713155926.zip (473.1 KB)

4 Likes

Thank you for your translation.
It would be nice if you could tell us something about it :slight_smile:
For example: As far as I know there a few different chinese dialects - which one did you use?

As of today 28 September 2021 the Dutch translation on transfix is completed.

kind regards,

Onno

3 Likes

Here is the Swedish translation (99%) OctoPrint-i18n-sv_20211005153016.zip

2 Likes

Thank you for your work!

it looks like dutch translation is not yet available. Still 5 strings to translate -> OctoPrint localization

Continuing the discussion from Translating OctoPrint:

OctoPrint-i18n-zh_CN_20211206062856.zip (490.2 KB)
裂开了Google身份验证器没了登不上原来的号了

New italian translation @foosel please, add to the language pack
OctoPrint-i18n-it_20211219220324.zip (513.2 KB)
or https://github.com/metronometro/Octoprint-italian-translation/blob/c88b9e440bd09f36edd9789945e76f40bf3a6267/OctoPrint-i18n-it_20211219220324.zip

I see that there is a bug, when install your pack on controls tab disappear all controls

with previous pack

the problem is in file .mo
where I can get updated .mo file?

1 Like

Hi, I have the same problem as you, how can you fix it?

italiano - Ciao, anche io ho il tuo stesso problema, come si può risolvere?

Octoprint Turkish (Türkçe) language pack
Octoprint_tr.zip (142.6 KB)
Github:

1 Like