PHPackages                             vanengers/catalog-translator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vanengers/catalog-translator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vanengers/catalog-translator
============================

Translate a MessageCatalog and save to disk

v1.0.2(2y ago)071MITPHP

Since Jan 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vanengers/catalog-translator)[ Packagist](https://packagist.org/packages/vanengers/catalog-translator)[ RSS](/packages/vanengers-catalog-translator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (1)

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
-------

[](#install)

` composer require --dev vanengers/catalog-translator`

Usage
-----

[](#usage)

```
$translator = new Translator(
    MessageCatalogue $extracted,
    array $translateTo => [],
    ?ITranslateClient $external = null,
    string $translations_config_file = ''
);
```

Example
-------

[](#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.

```
$extracted = new \Symfony\Component\Translation\MessageCatalogue('en-GB',[
    'domain' => [
        'This is a base language key' => 'This is a base language key'
    ]
]);
```

Create an array of locales to translate to.

```
$translateTo = ['nl-NL', 'de-DE'];
```

Load an external translator, in this case we are using Deepl.

```
$external = new \Vanengers\CatalogTranslator\Client\DeeplClient([
    'api_key' => 'your-deepl-api-key'
]);
```

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.

```
$translations_config_file = __DIR__ . '/translations.json';
```

External Translators
--------------------

[](#external-translators)

You can use any translator you want, as long as it implements the ITranslateClient.

```
class CustomTranslator implements ITranslateClient {}
```

### Available translators

[](#available-translators)

#### Deepl

[](#deepl)

```
$external = new \Vanengers\CatalogTranslator\Client\DeeplClient([
    'api_key' => 'your-deepl-api-key'
]);
```

Languages
---------

[](#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.

```
$languages = $external->getSourceLanguages();
```

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

```
public function translate(string $text, string $source, string $target): string
{
    $source = $this->fromLocaleToIso($source);
    $target = $this->fromLocaleToIso($source, true);
    return $this->api->translateText($text, $source, $target);
}
```

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.

```
public function getSourceLanguages(): array
{
    return array_map(function(Language $language) {
        return new Lang($language->code, $language->name, $this->fromIsoToLocale($language->code, false));
    }, $this->api->getSourceLanguages());
}
```

### Exceptions in iso/locale conversion

[](#exceptions-in-isolocale-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.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

860d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90f2324639ed35bd07704cf01a6c124478ec162147a7e60d0ca61cfd8f463a0a?d=identicon)[georgevanengers](/maintainers/georgevanengers)

---

Top Contributors

[![vanengers](https://avatars.githubusercontent.com/u/39123706?v=4)](https://github.com/vanengers "vanengers (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vanengers-catalog-translator/health.svg)

```
[![Health](https://phpackages.com/badges/vanengers-catalog-translator/health.svg)](https://phpackages.com/packages/vanengers-catalog-translator)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[symfony/asset-mapper

Maps directories of assets &amp; makes them available in a public directory with versioned filenames.

1656.9M131](/packages/symfony-asset-mapper)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
