Potrans it's PHP command line tool for automatic translation of Gettext PO file with Google Translator API.
Google Translate API pricing is based on usage. Translation usage is calculated in millions of characters (M), where 1 M = 106 characters. For more information, see the Pricing FAQ.
For more information about Google Translate API visit https://developers.google.com/translate/
See supported languages: https://developers.google.com/translate/v2/using_rest#language-params
- Go to the Google Cloud Console.
- Select a project.
- In the sidebar on the left, select APIs & auth. In the displayed list of APIs, make sure the Google Translate API status is set to ON.
- In the sidebar on the left, select Registered apps.
- Select an application.
See full Getting Started guide: https://developers.google.com/translate/v2/getting_started
- Install composer
curl -s http://getcomposer.org/installer | php
then runcomposer install
for install all dependencies. For more information about Composer visit: https://getcomposer.org - Install PHP Curl extension (php5-curl)
Follow example will translate whole content of members-cs_CZ.po
from English (default) to Czech language (default)
potrans -k 123456789 -i members-cs_CZ.po -v
Another example it's about output.
potrans -k 123456789 -i example_RU.po -o path/to/output_EN.po -f ru -t en
--------------------------------------------------------------------------------
PO translator parametters
--------------------------------------------------------------------------------
Flags
--verbose, -v Turn on verbose output
--help, -h Show help
Options
--apikey, -k Google Translate API Key
--input, -i Path to input PO file
--output, -o Path to output PO file (default: ./tmp/*.po)
--from, -f Source language (default: en) [default: en]
--to, -t Target language (default: cs) [default: cs]
Example
potrans -k 123456789 -i members-cs_CZ.po -v