PHPackages                             connectsb/translationbundle - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. connectsb/translationbundle

ActiveSymfony-bundle[Localization &amp; i18n](/categories/localization)

connectsb/translationbundle
===========================

Bundle which manages translations coupled to an specific entity

v1.0.1(11y ago)163MITPHP

Since Dec 15Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ConnectSB/symfony2-translations-bundle)[ Packagist](https://packagist.org/packages/connectsb/translationbundle)[ RSS](/packages/connectsb-translationbundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Symfony Translation Bundle
==========================

[](#symfony-translation-bundle)

With this Bundle you can edit defined translations in Symfony2. The edited translations are stored in two entities in your database.

1) Installation
---------------

[](#1-installation)

First you have to add the folowing lines to your `composer.json` file:

```
{
    "require": {
        "connectsb/translationbundle": "dev-master"
    }
}
```

You also have to add the TranslationBundle to your AppKernel.php:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new ConnectSB\TranslationBundle\ConnectSBTranslationBundle()
        );
    }
}
```

2) Usage
--------

[](#2-usage)

In `config.yml` you have to set the following parameters:

```
connect_sb_translation:
    database_translations_domain:   # name of the translation file (can't be messages)
    database_translations_entity:   # name of the entity for the translations

```

This bundle relies on two entities, BaseTranslationKey &amp; BaseTranslationValue. The key entity contains the keys of the translations while BaseTranslationValue contains the actual value of the key plus the locale.

The reason why you should extend both these entities is because you will have to define a relationship between the translations and your own entity.

An example of the class to extend BaseTranslationKey is:

```
/**
 * @ORM\Table()
 * @ORM\Entity
 */
class TranslationKey extends BaseTranslationKey
{
    /**
     * @ORM\OneToMany(targetEntity="TranslationValue", mappedBy="translationKey", cascade={"persist"})
     */
    protected $translationValues;

    /**
     * Define connection with your entity here
     *
     * @ORM\ManyToOne(targetEntity="ExampleEntity", inversedBy="translationKeys", cascade={"persist"})
     * @ORM\JoinColumn(name="example_entity_id", referencedColumnName="id")
     */
    private $exampleEntity;
}
```

Second you should extend the BaseTranslationValue class, an example of this class would look like:

```
/**
 * @ORM\Table()
 * @ORM\Entity
 */
class TranslationValue extends BaseTranslationValue
{
    /**
     * @ORM\ManyToOne(targetEntity="TranslationKey", inversedBy="translationValues", cascade={"persist"})
     * @ORM\JoinColumn(name="translation_key_id", referencedColumnName="id")
     */
    protected $translationKey;
}
```

The getters and setters are needed for both entities. Doctrine can create those getters and setters for you. You should execute the following command when located at the root of your project: `php app/console doctrine:generate:entities [nameOfYourFolder]`, where nameOfYourFolder should be the top folder of your bundle.

### 3) Forms

[](#3-forms)

This bundle contains a number of Forms. The Forms can be used to edit the translations. An example is shown below:

```
public function editTranslations(Request $request, ExampleEntity $exampleEntity)
{
    // Set the entity ID in the request so the bundle can read it
    $request->request->set('entityId', $exampleEntity->getId());

    /** TranslationKey[] $translations */
    $translations = $this->get('connect_sb_database_translation_service')->getTranslationsCollection();

    // Set the translationKeys (this is necessary in order to build the form)
    $exampleEntity->setTranslationKeys($translations);

    $form = $this->createForm(
        new TranslationsCollectionType($this->get('connect_sb_database_translation_service')), $exampleEntity
    );

    $form->handleRequest($request);

    if ($form->isValid()) {
        // Get the (edited) translationKeys from the form
        $translationKeys = $form->getData()->getTranslationKeys();

        /** TranslationKey[] $modifiedTranslationKeys */
        $modifiedTranslationKeys = $this->get('connect_sb_database_translation_service')->getModifiedTranslations($translationKeys);
        $exampleEntity->setTranslationKeys($modifiedTranslationKeys);

        // persist and flush
    }
      // return and render the form
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

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

Total

2

Last Release

4124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bcf9d7869c19ea708c1da4f1fb74d1513fb9b0fe84ebd8aeb4f8002fca9d3755?d=identicon)[timhovius](/maintainers/timhovius)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/connectsb-translationbundle/health.svg)

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

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)

PHPackages © 2026

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