gettext PO files translate by Yandex translator
Project description
========================================
PoTrans python3 library and console tool
========================================
Purpose
-------
Automatically translate gettext's *.po files to specified language, using Yandex Translate
Install
-------
::
# pip3 install potrans
Usage of library
----------------
To use it, use must acquire Yandex Translator API key here: https://tech.yandex.ru/keys/get/?service=trnsl
it looks like "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a"
::
from potrans import Translator
key = "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a"
translator = Translator(key)
translator.open_po_file("./en_US.po")
translator.go_translate("en", "de")
translator.save_po_file("./de_DE.po")
translator.save_mo_file("./de_DE.mo")
Usage of console script
-----------------------
Translate from Russian to Italian and save result to po-file:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po --key trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a
if you don't like to specify key every time, you can put it into ~/.config/potrans.key:
::
echo "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a" >> ~/.config/potrans.key
now, you can run the same command without key:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Translate and save result to *.po and *.mo files:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po -om ./it.IT.mo
Translate with outputting all the phrases and it's translate strings:
::
potrans translate --debug -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Translate, using msgid in case msgstr is empty:
::
potrans translate --usemsgid -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Just convert *.po to *.mo without translation:
::
potrans convert -i ./ru_RU.po -o ./ru_RU.mo
Change Log
==========
0.1.7 - Fixed bug where empty msgid translation caused error
Added autoreplace to strings like "%d", "%s", " ", "←"
0.1.6 - Changed cli, so, yandex_api key no longer needed to convert *.po to *.mo
Added cli.py script to run package cli interface in development
0.1.5 - Added changelogs to a package info
0.1.4 - Added some info to README.rst
0.1.0 - Initial release
PoTrans python3 library and console tool
========================================
Purpose
-------
Automatically translate gettext's *.po files to specified language, using Yandex Translate
Install
-------
::
# pip3 install potrans
Usage of library
----------------
To use it, use must acquire Yandex Translator API key here: https://tech.yandex.ru/keys/get/?service=trnsl
it looks like "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a"
::
from potrans import Translator
key = "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a"
translator = Translator(key)
translator.open_po_file("./en_US.po")
translator.go_translate("en", "de")
translator.save_po_file("./de_DE.po")
translator.save_mo_file("./de_DE.mo")
Usage of console script
-----------------------
Translate from Russian to Italian and save result to po-file:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po --key trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a
if you don't like to specify key every time, you can put it into ~/.config/potrans.key:
::
echo "trnsl.1.1.20160716T101753Z.a0378f5552843fb4.c5a82afc2a581d1e3717f92d4c753f3f798deb2a" >> ~/.config/potrans.key
now, you can run the same command without key:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Translate and save result to *.po and *.mo files:
::
potrans translate -i ./ru_RU.po -il ru -ol it -o ./it_IT.po -om ./it.IT.mo
Translate with outputting all the phrases and it's translate strings:
::
potrans translate --debug -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Translate, using msgid in case msgstr is empty:
::
potrans translate --usemsgid -i ./ru_RU.po -il ru -ol it -o ./it_IT.po
Just convert *.po to *.mo without translation:
::
potrans convert -i ./ru_RU.po -o ./ru_RU.mo
Change Log
==========
0.1.7 - Fixed bug where empty msgid translation caused error
Added autoreplace to strings like "%d", "%s", " ", "←"
0.1.6 - Changed cli, so, yandex_api key no longer needed to convert *.po to *.mo
Added cli.py script to run package cli interface in development
0.1.5 - Added changelogs to a package info
0.1.4 - Added some info to README.rst
0.1.0 - Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
PoTrans-0.1.7.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file PoTrans-0.1.7.tar.gz
.
File metadata
- Download URL: PoTrans-0.1.7.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13147efe6ba3e0296cc66c66cd80adb2d06f3cafdf66a15d1068680cc3951334 |
|
MD5 | c231adb663556b4d9f53d15f3a3b52a4 |
|
BLAKE2b-256 | a484b13d22ac759701341a748f1567ad07a1d404440fcc002750971c4ea8b099 |
File details
Details for the file PoTrans-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: PoTrans-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 820c87c12db12603a4d57864740e3b152f4d663e053fc97abcea572fc6c32e4e |
|
MD5 | 5710e29284088729940f5191e6bb2281 |
|
BLAKE2b-256 | 8319732adf35f8dcfa154b56429ac1c993b01ee7bdb0b3937e803ec1cf2f7c83 |