Download the PHP package om/potrans without Composer

On this page you can find all versions of the php package om/potrans. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package potrans

![Packagist Version](https://img.shields.io/packagist/v/om/potrans?style=for-the-badge) ![Packagist License](https://img.shields.io/packagist/l/om/potrans?style=for-the-badge) ![Packagist Downloads](https://img.shields.io/packagist/dm/om/potrans?style=for-the-badge)

PO file translator

Potrans is a PHP command line tool for automatic translation of Gettext PO files with Google Translator or DeepL Translator.

Install

You can add om/potrans to your PHP project as follows:

or you can clone this repository and then run ./bin/potrans

Google Translator

Example commands

Follow command will translate whole content of tests/example-cs_CZ.po from English (default) to Czech language ( default):

You can also change source and target language with --form and --to parametters:

Google Translate API Pricing

Google Translate API pricing is based on usage. Translation usage is calculated in millions of characters (M), where 1 M = 10^6 characters. For more information, see the Pricing FAQ.

Getting Google Translation Credentials

  1. Open Google Cloud Console website
  2. Create a new Project (or select existing one)
  3. Search for translate API and enable it then
  4. Go to IAM & Admin > Service Accounts and click to + Create service account
  5. Chose Service account name and Service account ID and click to Create and continue
  6. Grant this service account access to project and add follow roles Cloud Translation API Editor, AutoML Editor
  7. Create new Keys and download credentials JSON file

You can watch it here:

DeepL Translator

Example commands

DeepL Translator API pricing

DeepL Translator API pricing is based on a monthly subscription. There is a maximum of 500,000 characters/month for free.

For more information, visit DeepL Pro API.

Getting Api Key

  1. Register free Account
  2. Visit Account summary
  3. Find the Authentication Key for the DeepL API.

Environment variables

You can use environment variables to set the DeepL API key.

Custom translator

If you need to use a custom translator that behaves differently than the original translator, you have the option to use the --translator parameter as follows:

PHP file should contain implementation of Translator interface and should return new instance:

You can find an example custom translator in the file DeepLTranslatorEscaped.php

Potrans development

  1. Install composer curl -s http://getcomposer.org/installer | php
  2. Run composer install for install all dependencies
  3. Install PHP Curl extension (curl and json PHP extensions)

For more information about Composer, visit: https://getcomposer.org

If you get "command not found: potrans", just run the command like this: php bin/potrans and it will run without problems.

Troubleshooting

cURL error: SSL certificate issue (Google Translate only)

You may encounter a problem caused by cURL like the following:

This is due to a missing issuer certificate cacert.pem file, and curl won't verify SSL requests:

  1. Download http://curl.haxx.se/ca/cacert.pem
  2. Save is somewhere, e.g. /usr/local/etc/cacert.pem
  3. Update your php.ini with the following:

You can verify it with phpinfo() or php --info. Read more detailed instruction here.

Links


All versions of potrans with dependencies

PHP Build Version
Package Version
Requires symfony/console Version ^6.0
gettext/gettext Version ^5.6
google/cloud-translate Version ^1.12
symfony/cache Version ^6.0
deeplcom/deepl-php Version ^1.2
vlucas/phpdotenv Version ^5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package om/potrans contains the following files

Loading the files please wait ....