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 2d 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 26% 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

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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