A python package to easily translate po and pot files in any language supported by Google Translate.
Project description
potranslator
potranslator is a package to easily translate po and pot files generated by Sphinx or other tools in any language supported by Google Translate. | The Command Line Interface of potranslator follows the same pattern as 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
QuickStart for auto-translation with potranslator
This section describes how to translate documents generated with Sphinx with the potranslator command.
Create your document(s) by using Sphinx:
sphinx-build -b html \path\to\docs path\to\docs\_build
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.
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
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/
Translate/Update your documents in Japanese and Build the compiled mo files:
$ potranslator build $ make -e SPHINXOPTS="-D language='ja'" html
That’s all!
Basic Features
Translate or update po files from pot files.
Build mo files from po or pot files.
Requirements for the basic features
Python 3.6, 3.5, 3.4, 2.7, pypy.
external library: setuptools, six, babel, click, googletrans, polib
Optional features
These features need the transifex-client library.
create .transifexrc file from environment variable, without interactive input.
create .tx/config file without interactive input.
update .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 for below 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
Your transifex account if you want to upload/download po files from transifex.
external library: transifex-client
Installation
Recommended strongly: 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 languages:
export 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 _build/gettext directory, however pot files can be generated in the locale/pot 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
This utilty is derived from this project.
CHANGES
See: https://github.com/sphinx-doc/potranslator/blob/master/HISTORY.rst
History
1.0.0 (2018-07-05)
First release candidate.
Added Command Line Interface.
0.1.0 (2018-06-27)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file potranslator-1.0.3.tar.gz
.
File metadata
- Download URL: potranslator-1.0.3.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd6610e54b62bfc08172762c3c66e98dea315d9e554dba6458b236811fa62660 |
|
MD5 | 09f79ce80d2aaa381f8261ab1d32d0c5 |
|
BLAKE2b-256 | e76183157813e0965e1784c87dd372c87807873db3aaa2f2c25086090ba4c8ec |
File details
Details for the file potranslator-1.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: potranslator-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f28ee587ea4cdd59bfa84797fc74cb353f64a5a14b61234bd834fcdc569db2af |
|
MD5 | af5f617eab9a6a0fdd782d6efffd0ef1 |
|
BLAKE2b-256 | f2a9c5ea29a9276a34aa3b1e167332e5ca18f947c98e04cf159b7d737a9ce3eb |