PHPackages                             lucasweb/translations - 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. lucasweb/translations

ActiveSymfony-bundle

lucasweb/translations
=====================

This Bundle adds extra commands to Symfony for easy managing translations. With Yandex Translate API support for automatic translations.

1.0.4(8y ago)3237↓100%1MITPHPPHP &gt;=5.6.3

Since Jan 27Pushed 8y agoCompare

[ Source](https://github.com/LucasWeb2016/TranslationsExtraBundle)[ Packagist](https://packagist.org/packages/lucasweb/translations)[ Docs](https://github.com/LucasWeb2016/TranslationExtraBundle)[ RSS](/packages/lucasweb-translations/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Lucasweb\\TranslationsExtraBundle
=================================

[](#lucaswebtranslationsextrabundle)

[![Symfony](https://camo.githubusercontent.com/9d290f969722eb60ec5ce3ab295457c9dfb4870f693cbb287a402e70fe3dfb71/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d342d677265656e2e737667)](https://symfony.com/) [![License](https://camo.githubusercontent.com/c9976f14039bee981f255ff250600a1e78489f3c6e442422638ffe9b6e016af2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d6f72616e67652e737667)](https://github.com/LucasWeb2016/TranslationsExtraBundle/blob/master/LICENSE) [![Stable](https://camo.githubusercontent.com/7138ef68354d2bb527049a5b0672139fb58186081baa8f640dc7fbea60bdc396/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537461626c652d312e302e342d626c75652e737667)](https://github.com/LucasWeb2016/TranslationsExtraBundle/releases/tag/1.0) [![Stable](https://camo.githubusercontent.com/27912585de37d18dc789be4a35abc894ed2d0c5e79a8ba4e4f9f4446effae6de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f556e737461626c652d6465762d2d6d61737465722d7265642e737667)](https://github.com/LucasWeb2016/TranslationsExtraBundle)

[![knpbundles.com](https://camo.githubusercontent.com/fb823c62c2b6ce9b9f4f797960c1c151244c18ea7f321d42e6b442fec743db0b/687474703a2f2f6b6e7062756e646c65732e636f6d2f4c75636173576562323031362f5472616e736c6174696f6e73457874726142756e646c652f62616467652d73686f7274)](http://knpbundles.com/LucasWeb2016/TranslationsExtraBundle)

**Bundle with extra developer tools for Symfony Framework**

This Bundle adds extra commands to Symfony for easy managing translations. With Yandex Translate API support for automatic translations.

- Add a new translation message
- Edit a translation message
- Search in translation files
- Remove a translation message
- Get info from a translation message
- Check translation files
- Sync translation files
- Create translation files
- Import translation files
- Automatic translate with Yandex Translate API

Why create this Bundle?
-----------------------

[](#why-create-this-bundle)

Honestly, I hate having to change tab when I need to create a new message while I'm working on a Twig template or a controller.

The first idea was to create a command that would create new messages in a simple way, but I needed other functions, so I added them.

I am currently improving the bundle and expanding functionalities every day.

If you found a bug, please [create an issue](https://github.com/LucasWeb2016/TranslationsExtraBundle/issues) !!

I hope you find it useful!

Requeriments
============

[](#requeriments)

- Symfony &gt;3.4 (Not tested in previous versions)
- PHP &gt;5.6.3
- [Yandex/Translate-api](https://github.com/yandex-php/translate-api) 1.5.x

Documentation
=============

[](#documentation)

Installation
------------

[](#installation)

```
composer require lucasweb/translations

```

Configuration
-------------

[](#configuration)

This Bundle only need this config to start working:

```
translations_extra:
    default_format: 'xml'
    default_locale: 'es'
    other_locales: ['en,'fr']
    domains: ['messages','validators']
    main_folder: '%kernel.project_dir%/translations/'
    yandex_api_key: 'trnsl.1.1.4e434e....'

```

- **default\_format (string, required)** : Format to be used by default in new files created by this bundle. Valid values are 'xml', 'yaml' and 'php'
- **default\_locale (string, required)** : Default locale in your symfony project. (Ex. 'en' or 'fr')
- **other\_locales (array, required)** : Array with other locales used in your project (Ex. \['en','fr'\]. This can be an empty array if you want to use this Bundle only for your default locale. This configuration is required, but can be an empty array if no other locales.
- **domains (array, required)** : Array with domains that will be accesible by this bundle. "messages" and "validators" are default domains in Symfony.
- **main\_folder (string, required)** : Main folder where translation files are stored.
- **yandex\_api\_key (string, optional)** : Yandex Translate API key from [here](http://api.yandex.com/key/form.xml?service=trnsl) . If configured, Yandex Translation will be activated.

How to use this bundle
======================

[](#how-to-use-this-bundle)

Add a new translation message
-----------------------------

[](#add-a-new-translation-message)

This command adds a new message to all the locales of a domain if file exists.

```
 php bin/console trans:add domainname

```

**Example**

```
php bin/console trans:add messages

TRANS:ADD => INFO : Starting Add Process ...
TRANS:ADD => QUESTION : Please, enter unique ID for the new message : label.name
TRANS:ADD => INFO : The ID you have entered is valid!
TRANS:ADD => QUESTION : Please, enter value for ID="label.name" in file "messages.es.xliff" : Nombre
TRANS:ADD => QUESTION : Please, enter value for ID="label.name" in file "messages.en.xliff" (Yandex Translation: Name ) : Name
TRANS:ADD => QUESTION : Please, enter value for ID="label.name" in file "messages.fr.xliff" (Yandex Translation: Nom ) : Nom
TRANS:ADD => SUCCESS : Translation message created!

```

Search
------

[](#search)

Search for a string in all translation files of a domain.

```
 php bin/console trans:search "searchterm" domainname

```

**Example**

```
php bin/console trans:search "Nombre" messages

TRANS:SEARCH => INFO : Starting Search Process ...

+--------+-------------------+------------------+-------------------+
| Locale | File              | ID               | Value             |
+--------+-------------------+------------------+-------------------+
| es     | messages.es.xliff | label.name       | Nombre            |
| es     | messages.es.xliff | profile.username | Nombre de usuario |
+--------+-------------------+------------------+-------------------+

```

Edit a translation message
--------------------------

[](#edit-a-translation-message)

This command edits an ID in all the locales of a domain if file exists.

```
 php bin/console trans:edit ID domainname

```

**Example**

```
php bin/console trans:edit label.name messages

TRANS:EDIT => INFO : Starting Edit Process ...
TRANS:EDIT => INFO : ID="label.name" found in file "messages.es.xliff".
TRANS:EDIT => QUESTION : New value for ID=label.name in default file messages.es.xliff (Current="Nombre") : Nombre completo
TRANS:EDIT => INFO : ID="label.name" found in file "messages.en.xliff".
TRANS:EDIT => QUESTION : New value for ID=label.name in file messages.en.xliff (Current="Name") (Yandex Translation: Full name ) : Full name
TRANS:EDIT => INFO : ID="label.name" found in file "messages.fr.xliff".
TRANS:EDIT => QUESTION : New value for ID=label.name in file messages.fr.xliff (Current="Nom") (Yandex Translation: Nom complet ) : Nom complet
TRANS:EDIT => SUCCESS : Translation message edited and saved!

```

Remove a translation message
----------------------------

[](#remove-a-translation-message)

This commands removes an ID from all the locales of a domain if file exists, even if it's being used in the project.

```
 php bin/console trans:edit ID domainname

```

**Example**

```
php bin/console trans:remove label.name messages

TRANS:REMOVE => INFO : Starting Remove Process ...
TRANS:REMOVE => INFO : ID="label.name" found in default file "messages.es.xliff".
TRANS:REMOVE => WARNING : Translation ID="label.name" will be deleted from default file "messages.es.xliff", even if it is being used in the project. Continue? (y/n) : y
TRANS:REMOVE => SUCCESS : Translation message ID="label.name" removed from default file "messages.es.xliff"!
TRANS:REMOVE => INFO : ID="label.name" found in file "messages.en.xliff".
TRANS:REMOVE => WARNING : Translation ID="label.name" will be deleted from file "messages.en.xliff", even if it is being used in the project. Continue? (y/n) : y
TRANS:REMOVE => SUCCESS : Translation message ID="label.name" removed from file "messages.en.xliff"!
TRANS:REMOVE => INFO : ID="label.name" found in file "messages.fr.xliff".
TRANS:REMOVE => WARNING : Translation ID="label.name" will be deleted from file "messages.fr.xliff", even if it is being used in the project. Continue? (y/n) : y
TRANS:REMOVE => SUCCESS : Translation message ID="label.name" removed from file "messages.fr.xliff"!

```

Get info from a translation message
-----------------------------------

[](#get-info-from-a-translation-message)

This command shows all locale translations of a ID

```
 php bin/console trans:info ID domainname

```

**Example**

```
php bin/console trans:info label.name messages

TRANS:INFO => INFO : Starting Info Process ...

+--------+-------------------+------------+--------+
| Locale | File              | ID         | Value  |
+--------+-------------------+------------+--------+
| es     | messages.es.xliff | label.name | Nombre |
+--------+-------------------+------------+--------+
| en     | messages.en.yml   | label.name | Name   |
+--------+-------------------+------------+--------+
| fr     | messages.fr.xliff | Not found! |        |
+--------+-------------------+------------+--------+

TRANS:INFO => SUCCESS : Translation message info shown!

```

Check translation files
-----------------------

[](#check-translation-files)

Checks locale files supposed to exist for a domain, and report problems.

```
 php bin/console trans:check domainname

```

**Example**

```
php bin/console trans:remove label.name messages

TRANS:CHECK => INFO : Starting Check Process ...

+--------+-------------------+--------+----------+--------------------------------------------------------------------------------------------+
| Locale | File              | Format | Messages | Status                                                                                     |
+--------+-------------------+--------+----------+--------------------------------------------------------------------------------------------+
| es     | messages.es.xliff | xml    | 9        | Ok!                                                                                        |
+--------+-------------------+--------+----------+--------------------------------------------------------------------------------------------+
| en     | messages.en.xliff | xml    | 8        | Different quantity of messages than default locale, Run "trans:sync messages" to solve it! |
+--------+-------------------+--------+----------+--------------------------------------------------------------------------------------------+
| fr     | messages.fr.???   | ???    | 0        | File not found, Run "trans:create messages" to solve it!                                   |
+--------+-------------------+--------+----------+--------------------------------------------------------------------------------------------+

TRANS:CHECK => SUCCESS : Check process finished!

```

Sync translations files
-----------------------

[](#sync-translations-files)

This command checks that all translation files of a domain have the same number of messages, and in case of finding some missing translation, gives the option to create a new message in the file where it is missing, or to delete the message from the file where it was found .

```
 php bin/console trans:sync domainname

```

**Example**

```
php bin/console trans:sync messages

TRANS:SYNC => INFO : Starting Sync Process ...
TRANS:SYNC => INFO : Comparing messages.es.xliff -> messages.en.xliff
TRANS:SYNC => INFO : ID="menu.login" with value "Inicio de sesión" is in default file messages.es.xliff but not in messages.en.xliff. Create(1) or Delete(2) : 1
TRANS:SYNC => QUESTION : Value for messages.en.xliff (Yandex Translation: Login ) : Login
TRANS:SYNC => INFO : ID="menu.login"" created in messages.en.xliff!
TRANS:SYNC => INFO : Comparing messages.en.xliff -> messages.es.xliff
TRANS:SYNC => INFO : ID="profile.username" with target "Username" is in messages.en.xliff but not in default file messages.es.xliff. Create(1) or Delete(2) : 1
TRANS:SYNC => QUESTION: Value for default file messages.es.xliff (Yandex Translation: Nombre de usuario ) : Nombre de usuario
TRANS:SYNC => INFO : ID=profile.username created in default file messages.es.xliff
TRANS:SYNC => SUCCESS : Process finished!
TRANS:SYNC => INFO : Comparing messages.es.xliff -> messages.fr.xliff
TRANS:SYNC => INFO : ID="menu.home" with value "Inicio" is in default file messages.es.xliff but not in messages.fr.xliff. Create(1) or Delete(2) : 1
TRANS:SYNC => QUESTION : Value for messages.fr.xliff (Yandex Translation: Démarrer ) :
TRANS:SYNC => INFO : ID="menu.home"" created in messages.fr.xliff!
TRANS:SYNC => INFO : ID="profile.username" with value "Nombre de usuario" is in default file messages.es.xliff but not in messages.fr.xliff. Create(1) or Delete(2) : 1
TRANS:SYNC => QUESTION : Value for messages.fr.xliff (Yandex Translation: Nom d'utilisateur ) : Nom d'utilisateur
TRANS:SYNC => INFO : ID="profile.username"" created in messages.fr.xliff!
TRANS:SYNC => INFO : Comparing messages.fr.xliff -> messages.es.xliff
TRANS:SYNC => SUCCESS : Process finished!

```

Create translation files
------------------------

[](#create-translation-files)

This command checks the existence of all the files that must exist according to the locales and domains configured, and allows you to create both empty files and clones of the default locale.

```
 php bin/console trans:create domainname

```

**Example**

```
php bin/console trans:create messages

TRANS:CREATE => INFO : Starting Create Process ...
TRANS:CREATE => INFO : Default File "messages.es.xliff" exists!
TRANS:CREATE => QUESTION : File for domain "messages" and locale "en" not found!
  [0] Skip
  [1] Create new empty file
  [2] Create a clon of default file
  [3] Create a clon of default file and translate it with Yandex Translate API
 > 3
TRANS:CREATE => SUCCESS : File "messages.en.xliff" with Yandex Translation from default file create!
TRANS:CREATE => INFO : File "messages.fr.xliff" exists!

```

Import translations files
-------------------------

[](#import-translations-files)

In Symfony you can override translation messages from bundles in main folder. This commands checks a path or a composer installed package for translation files for locales in a domain, and imports them to main folder, where you can easily modify them.

```
 php bin/console trans:import bundle/package domainname

```

**Example**In this example, the command imports Vich Uploader translation files to our main folder according to locales and default format configured, and in the default format . Not needed files will not be imported.

```
php bin/console trans:import Vich\Uploader-Bundle VichUploaderBundle

TRANS:IMPORT => INFO : Starting Import Process ...
TRANS:IMPORT => INFO : Folder "Vich\Uploader-Bundle" found !!.
TRANS:IMPORT => INFO : File "VichUploaderBundle.es.yml" located in folder "C:\xampp\htdocs\symfny4\src/../vendor/vich\uploader-bundle/Resources/Translations"!
TRANS:IMPORT => QUESTION : Import this translation file content (y/n) : y
TRANS:IMPORT => SUCCESS : File "VichUploaderBundle.es.xliff" created with imported data.
TRANS:IMPORT => INFO : File "VichUploaderBundle.en.yml" located in folder "C:\xampp\htdocs\symfny4\src/../vendor/vich\uploader-bundle/Resources/Translations"!
TRANS:IMPORT => QUESTION : Import this translation file content (y/n) : y
TRANS:IMPORT => SUCCESS : File "VichUploaderBundle.en.xliff" created with imported data.
TRANS:IMPORT => INFO : File "VichUploaderBundle.fr.yml" located in folder "C:\xampp\htdocs\symfny4\src/../vendor/vich\uploader-bundle/Resources/Translations"!
TRANS:IMPORT => QUESTION : Import this translation file content (y/n) : y
TRANS:IMPORT => SUCCESS : File "VichUploaderBundle.fr.xliff" created with imported data.
TRANS:IMPORT => INFO : Process finished!
TRANS:IMPORT => IMPORTANT : Remember to add "VichUploaderBundle" domain to configuration or this files will be ignored by this Bundle.

```

You can also import files from any folder. The following command would do the same as the previous example:

```
php bin/console trans:import C:\xampp\htdocs\symfny4\vendor\vich\uploader-bundle\Resources\Translations VichUploaderBundle

```

License
=======

[](#license)

This bundle is under the MIT license. See the complete license in the bundle.

Reporting an issue or a feature request
=======================================

[](#reporting-an-issue-or-a-feature-request)

Issues and feature requests are tracked in the [Github issue tracker](https://github.com/LucasWeb2016/TranslationsExtraBundle/issues).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~1 days

Total

5

Last Release

3020d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/91d3d28c7af60e01124c565a9e57679908e77ddb8e05b15089a10c0c48f09caa?d=identicon)[LucasWeb](/maintainers/LucasWeb)

---

Top Contributors

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

---

Tags

symfony-automatic-translationsymfony-bundlesymfony-consolesymfony-translationconsole-commandssymfony-translationssymfony xliffsymfony translations managersymfony automatic translation

### Embed Badge

![Health badge](/badges/lucasweb-translations/health.svg)

```
[![Health](https://phpackages.com/badges/lucasweb-translations/health.svg)](https://phpackages.com/packages/lucasweb-translations)
```

###  Alternatives

[tanmuhittin/laravel-google-translate

Translate translation files to other languages using google translate api

4312.2M11](/packages/tanmuhittin-laravel-google-translate)

PHPackages © 2026

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