Download the PHP package vanengers/catalog-translator without Composer
On this page you can find all versions of the php package vanengers/catalog-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vanengers/catalog-translator
More information about vanengers/catalog-translator
Files in vanengers/catalog-translator
Package catalog-translator
Short Description Translate a MessageCatalog and save to disk
License MIT
Informations about the package catalog-translator
catalog-translator
Translates a whole catalog and saves it to disk for re-use. By default we are using Deepl for translations, but you can use any translator you want.
This is for development usage. This should not be used in a production environment.
Install
composer require --dev vanengers/catalog-translator
Usage
``
Example
First create a catalog with the base language keys, this is the language you want to translate from. So the key is the same as the value. ``
Create an array of locales to translate to.
``
Load an external translator, in this case we are using Deepl. ``
Location of the translations json file to retrieve and store translations. This file will be created if it does not exist. Existing translations will be used if the file exists and not be translated again. ``
External Translators
You can use any translator you want, as long as it implements the ITranslateClient. ``
Available translators
Deepl
``
Languages
Each external translator has its own set of languages it supports. You can retrieve these languages by calling the getSourceLanguages() or getTargetLanguages() methods on the translator.
``
The iso and locale codes from the external translator are not always the same as the ones. Convert them using the config/languages.json file.
You should do this with every External client so it matches the languages in the config file.
We use locales throughout the application, but the external translator might use iso codes. This differs per external translator
``
And when parsing the languages from the external translator, convert them to locales. In this case we have Language objects from Deepl. But this differs per external translator. ``
Exceptions in iso/locale conversion
Within the catalog-translator we use locales. For example: en-GB is supported here. When converting the locale en-GB to iso, we get "gb", officially this is a correct iso language code.
But Deepl doesn't allow this code to be a language source. So translate "gb" to "en" when it's a source language.
Deepl does however accept "en-gb" as an iso-code for a target language.
So keep in mind when implementing a new external translator! Use the languages.json file to convert the iso codes to locales and vice versa.
All versions of catalog-translator with dependencies
ext-json Version *
symfony/translation Version *
symfony/filesystem Version *
symfony/http-client Version 4.4.51
nyholm/psr7 Version ^1.8@dev