PHPackages                             benedicthelfer/translatable-form-field - 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. benedicthelfer/translatable-form-field

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

benedicthelfer/translatable-form-field
======================================

A Symfony2/3 bundle responsible for translatable form fields using sonata admin.

21013PHP

Since Feb 13Pushed 7y ago3 watchersCompare

[ Source](https://github.com/benedicthelfer/translatable-form-field)[ Packagist](https://packagist.org/packages/benedicthelfer/translatable-form-field)[ RSS](/packages/benedicthelfer-translatable-form-field/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

translatable-form-field
=======================

[](#translatable-form-field)

This bundle is responsible for translatable form fields in symfony2 / sonata admin.

Usage:

- add to 'AppKernel'

```
public function registerBundles()
{
    $bundles = array(
    // ...
    new Bnh\TranslatableFieldBundle\BnhTranslatableFieldBundle()
    );
}

```

- config

```
bnh_translatable_field:
    default_locale: en_GB
    locales: ['de_DE', 'en_GB', 'es_ES', 'fr_FR', 'hu_HU', 'ru_RU', 'sv_SE']
    templating: 'BnhTranslatableFieldBundle:FormType:bnhtranslations.html.twig'

```

- entity (ext\_translations)

```
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
// ...

class YourEntity implements Translatable
{
    /**
     * @Gedmo\Translatable
     * @ORM\Column(...
     */
    private $fieldname;

    public function setfieldname($fieldname)
    {
        $this->fieldname = $fieldname;
        return $this;
    }

    /**
     * @Gedmo\Locale
     */
    private $locale;

    public function setTranslatableLocale($locale)
    {
        $this->locale = $locale;
    }
}

```

- entity (for personal translations)

```
/**
 * @ORM\Entity
 * @Gedmo\TranslationEntity(class="YourEntityTranslation")
 */
class YourEntity
{
    /**
     * @ORM\OneToMany(targetEntity="YourEntityTranslation", mappedBy="object", cascade={"persist", "remove"})
     */
    private $translations;

    public function __construct()
    {
        $this->translations = new ArrayCollection();
    }

    public function getTranslations()
    {
        return $this->translations;
    }

    public function addTranslation(YourEntityTranslation $newTranslation)
    {
        if($newTranslation->getContent())
        {
            $found = false;
            foreach($this->translations as $translation)
            {
                if(($translation->getLocale() === $newTranslation->getLocale()) && ($translation->getField() === $newTranslation->getField()))
                {
                    $found = true;
                    $translation->setContent($newTranslation->getContent());
                    break;
                }
            }

            if(!$found)
            {
                $newTranslation->setObject($this);
                $this->translations[] = $newTranslation;
            }
        }
    }

    public function hasTranslation($locale, $fieldName)
    {
        foreach ($this->translations as $translation)
        {
            if(($translation->getLocale() === $locale) && ($translation->getField() === $fieldName))
            {
                return true;
            }
        }

        return false;
    }
}

```

- sonata admin page

```
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper->add('fieldname', 'bnhtranslations');
    }

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d718f228c4ccbf84ca1de0e9d11812210e6742a4aa004d91040c98163c699bf?d=identicon)[benedict](/maintainers/benedict)

---

Top Contributors

[![benedicthelfer](https://avatars.githubusercontent.com/u/1705341?v=4)](https://github.com/benedicthelfer "benedicthelfer (2 commits)")[![pzsprog](https://avatars.githubusercontent.com/u/15105156?v=4)](https://github.com/pzsprog "pzsprog (2 commits)")[![rufinus](https://avatars.githubusercontent.com/u/343160?v=4)](https://github.com/rufinus "rufinus (1 commits)")

### Embed Badge

![Health badge](/badges/benedicthelfer-translatable-form-field/health.svg)

```
[![Health](https://phpackages.com/badges/benedicthelfer-translatable-form-field/health.svg)](https://phpackages.com/packages/benedicthelfer-translatable-form-field)
```

###  Alternatives

[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[statikbe/laravel-chained-translator

The Laravel Chained Translator can combine several translators that can override each others translations.

36149.4k6](/packages/statikbe-laravel-chained-translator)

PHPackages © 2026

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