Skip to main content

potranslator

Pypi Python Package Index Status Linux Continuous Integration Status Windows Continuous Integration Status Documentation Status Depedencies Update Status Python 3 Readiness Code Coverage Status Code Vulnerability Status

potranslator is a package to easily translate po and pot files generated by Sphinx or other tools in any language supported by Google Translate.

potranslator auto-detects the language in the original pot files and auto-translates the pot files into the supplied target languages.

The Command Line Interface of potranslator and its documentation are based on sphinx-intl.

Optional: supports the Transifex collaborative service to upload the auto-generated translations to transifex for collaborative corrections of the translations.

Supported Languages

  • Afrikaans af

  • Albanian sq

  • Amharic am

  • Arabic ar

  • Armenian hy

  • Azeerbaijani az

  • Basque eu

  • Belarusian be

  • Bengali bn

  • Bosnian bs

  • Bulgarian bg

  • Catalan ca

  • Cebuano ceb (ISO-639-2)

  • Chinese (Simplified) zh-CN (BCP-47)

  • Chinese (Traditional) zh-TW (BCP-47)

  • Corsican co

  • Croatian hr

  • Czech cs

  • Danish da

  • Dutch nl

  • English en

  • Esperanto eo

  • Estonian et

  • Finnish fi

  • French fr

  • Frisian fy

  • Galician gl

  • Georgian ka

  • German de

  • Greek el

  • Gujarati gu

  • Haitian Creole ht

  • Hausa ha

  • Hawaiian haw (ISO-639-2)

  • Hebrew iw

  • Hindi hi

  • Hmong hmn (ISO-639-2)

  • Hungarian hu

  • Icelandic is

  • Igbo ig

  • Indonesian id

  • Irish ga

  • Italian it

  • Japanese ja

  • Javanese jw

  • Kannada kn

  • Kazakh kk

  • Khmer km

  • Korean ko

  • Kurdish ku

  • Kyrgyz ky

  • Lao lo

  • Latin la

  • Latvian lv

  • Lithuanian lt

  • Luxembourgish lb

  • Macedonian mk

  • Malagasy mg

  • Malay ms

  • Malayalam ml

  • Maltese mt

  • Maori mi

  • Marathi mr

  • Mongolian mn

  • Myanmar (Burmese) my

  • Nepali ne

  • Norwegian no

  • Nyanja (Chichewa) ny

  • Pashto ps

  • Persian fa

  • Polish pl

  • Portuguese (Portugal, Brazil) pt

  • Punjabi pa

  • Romanian ro

  • Russian ru

  • Samoan sm

  • Scots Gaelic gd

  • Serbian sr

  • Sesotho st

  • Shona sn

  • Sindhi sd

  • Sinhala (Sinhalese) si

  • Slovak sk

  • Slovenian sl

  • Somali so

  • Spanish es

  • Sundanese su

  • Swahili sw

  • Swedish sv

  • Tagalog (Filipino) tl

  • Tajik tg

  • Tamil ta

  • Telugu te

  • Thai th

  • Turkish tr

  • Ukrainian uk

  • Urdu ur

  • Uzbek uz

  • Vietnamese vi

  • Welsh cy

  • Xhosa xh

  • Yiddish yi

  • Yoruba yo

  • Zulu zu

Quick Start for auto-translation with potranslator

This section describes how to translate documents generated by Sphinx with the potranslator command.

  1. Create your document(s) by using Sphinx:

    $ sphinx-build -b html /path/to/docs path/to/docs/_build
  2. Optionally add the settings to your conf.py if you have one:

    locale_dirs = ['locale/']   #path is an example but this is the recommended path.
    gettext_compact = False     #optional.

    locale_dirs is required and gettext_compact is optional.

  3. Extract the document’s translatable messages into pot files (make sure you are in the folder containing make.bat and Makefile if you are on windows):

    $ make gettext
  4. Translate/Update your documents in German and Japanese:

    $ potranslator update -p _build/gettext -l de -l ja

    Done. You got these directories that contain po files with auto-translated entries:

    ./locale/de/LC_MESSAGES/
    ./locale/ja/LC_MESSAGES/
  5. Translate/Update your documents in Japanese, build the compiled mo files and generate the translated html documents:

    Command line (for Unix systems):

    $ potranslator build
    $ make -e SPHINXOPTS="-D language='ja'" html

    Command line (for Windows cmd.exe):

    > set SPHINXOPTS=-D language=de
    > potranslator build
    > .\make.bat html

    Command line (for PowerShell):

    > Set-Item env:SPHINXOPTS "-D language=de"
    > potranslator build
    > .\make.bat html

That’s all!

Basic Features

  • Translate from pot files or update existing po files with auto-generated translation.

  • Build mo files from translated po or pot files.

Requirements for the basic features

Optional features

These features need the transifex-client library.

  • create a .transifexrc file from an environment variable, without interactive input.

  • create a .tx/config file without interactive input.

  • update a .tx/config file from locale/pot files automatically.

  • build mo files from po files in the locale directory.

You need to use the tx command to use the following features:

  • tx push -s : push pot (translation catalogs) to transifex.

  • tx pull -l ja : pull po (translated catalogs) from transifex.

Requirements for the optional features

Installation

It is strongly recommended to use virtualenv for this procedure:

$ pip install potranslator

If you want to use the Optional Features, you need install this additional library:

$ pip install potranslator[transifex]

Commands, options, environment variables

Commands

Type potranslator without arguments to show the help instructions.

Setup environment variables

All command-line options can be set with environment variables using the format POTRANSLATOR_<UPPER_LONG_NAME> .

Dashes (-) have to replaced with underscores (_).

For example, to set the target languages:

$ export POTRANSLATOR_LANGUAGE=de,ja

On the Windows command line:

> set POTRANSLATOR_LANGUAGE=de,ja

This is the same as passing the option to potranslator directly:

$ potranslator <command> --language=de --language=ja

Setup sphinx conf.py

Add the following settings to your sphinx document’s conf.py if it exists:

locale_dirs = ['locale/']   #for example
gettext_compact = False     #optional

Setup Makefile / make.bat

make gettext will generate pot files into the _build/gettext directory, however pot files can be generated in the locale/pot directory if convenient.

You can do that by replacing _build/gettext with locale/pot in your Makefile and/or make.bat that was generated by sphinx-quickstart.

License

Licensed under the BSD license. See the LICENSE file for specific terms.

Original

The Command Line Interface and the transifex integration of potranslator are adapted from sphinx-intl.

CHANGES

See: https://github.com/SekouD/potranslator/blob/master/HISTORY.rst

History

1.1.0 (2018-07-08)

  • Now uses importlib_ressources for faster startup from CLI.

  • Updated the command line usability.

  • Added Type Annotation compliant with PEP 561.

  • Updated Documentation.

1.0.5 (2018-07-06)

  • Updated Documentation.

  • Translated the documentation in French, Spanish, Italian, German, Italian, Japanese and Chinese.

  • More detailed updates to the po files meta-data.

1.0.0 (2018-07-05)

  • First release candidate.

  • Added Command Line Interface.

0.1.0 (2018-06-27)

  • First release on PyPI.

Metadata

Release files for potranslator 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for potranslator 1.1.5
File Size Uploaded
potranslator-1.1.5.tar.gz 85.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for potranslator 1.1.5
File Interpreter ABI Platform
potranslator-1.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 331.9 kB

Release files / potranslator-1.1.5.tar.gz

Download URL potranslator-1.1.5.tar.gz
Size 85.1 kB
Tags Source
SHA-256 checksum
How to use checksums
230ec5fea71b96d839240b5e583d45a7f13a00a7d5cdd7d844840f6645e014d5
BLAKE2b-256 checksum
How to use checksums
64dd4b7b81fb5fd94accc37b574c0d78538d852b2cbd9b644bd89cb3ac73cb52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release files / potranslator-1.1.5-py2.py3-none-any.whl

Download URL potranslator-1.1.5-py2.py3-none-any.whl
Size 246.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ea69c569f063870881af0321ddcd2fbbd62adea19bbebd829185f3324eaae770
BLAKE2b-256 checksum
How to use checksums
6a4b253c4c0058991a63934185773acfd5d389caef2ba18a83989b5e37a29cf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files

1.1.4

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page