PHPackages                             sonofwinter/translation-bundle - 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. sonofwinter/translation-bundle

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

sonofwinter/translation-bundle
==============================

This Bundle provides a translator from Entity

1.1.0(8mo ago)11.0kMITPHPPHP &gt;=8.2CI failing

Since Jul 9Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/SonOfWinter/TranslationBundle)[ Packagist](https://packagist.org/packages/sonofwinter/translation-bundle)[ RSS](/packages/sonofwinter-translation-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (9)Versions (34)Used By (0)

SOWTranslationBundle
====================

[](#sowtranslationbundle)

This Bundle provides a translator for Symfony entities.

Prerequisites
-------------

[](#prerequisites)

- PHP 8.2 or higher
- Symfony 7.0 or higher
- Composer

Breaking Changes in v1.1
------------------------

[](#breaking-changes-in-v11)

In the Translatabe trait, the getId() method has been renamed to getIdentifier() to avoid conflicts with existing getId() methods in entities.

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

[](#installation)

Open a command console, enter your project directory and execute:

```
$ composer require sonofwinter/translation-bundle
```

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

[](#configuration)

### Bundle Registration

[](#bundle-registration)

Register the bundle in your `config/bundles.php`:

```
return [
    // ...
    SOW\TranslationBundle\SOWTranslationBundle::class => ['all' => true],
];
```

### Available Locales

[](#available-locales)

You can override the default available locales by setting the `sow_translation.available_locales` parameter:

```
parameters:
    sow_translation.available_locales: ['en', 'fr', 'es', 'de', 'it']
```

### Custom Translation Entity

[](#custom-translation-entity)

By default, a Translation entity class is provided, but you can create your own translation entity class that extends AbstractTranslation. To use it, set the `sow_translation.translation_class_name` parameter:

```
parameters:
    sow_translation.translation_class_name: App\Entity\YourTranslationClass
```

Usage
-----

[](#usage)

### Setting Up Translatable Entities

[](#setting-up-translatable-entities)

Your translated entities must implement the `Translatable` interface. Then define translated properties in your entity using either annotations or attributes.

#### Using Attributes (PHP 8.0+)

[](#using-attributes-php-80)

```
use SOW\TranslationBundle\Attribute\Translation;

class MyClass {
    #[Translation(key: "firstname")]
    private string $firstname = '';

    #[Translation(key: "lastname", setter: "setOtherName")]
    private string $lastname = '';
}
```

### Configuration Notes

[](#configuration-notes)

- The `key` property can be used to specify a different name for the translation key. If not provided, the property name is used.
- The `setter` property allows you to specify a custom setter method. If the setter doesn't exist, a `TranslatableConfigurationException` will be thrown.

Translation Methods
-------------------

[](#translation-methods)

### Translating Entities

[](#translating-entities)

```
// Translate an entity to a specific language
$translator->translate($entity, 'en');

// Translate an entity to multiple languages
$translator->translateForLangs($entity, ['en', 'fr', 'de']);
```

### Setting Translations

[](#setting-translations)

```
// Set a single translation
$translator->setTranslationForLangAndValue($entity, 'en', 'firstname', 'John');

// Set multiple values for one language
$translator->setTranslationForLangAndValues($entity, 'en', [
    'firstname' => 'John',
    'lastname' => 'Doe'
]);

// Set multiple translations for multiple languages
$translator->setTranslations($entity, [
    'en' => [
        'firstname' => 'John',
        'lastname' => 'Doe'
    ],
    'fr' => [
        'firstname' => 'Jean',
        'lastname' => 'Dupont'
    ]
]);
```

### Removing Translations

[](#removing-translations)

```
// Remove a specific translation
$translator->removeByObjectKeyAndLang($entity, 'firstname', 'en');

// Remove all translations for an entity
$translator->removeAllForTranslatable($entity);

// Remove all translations for a specific key
$translator->removeAllByKey('firstname');
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance59

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

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

Recently: every ~177 days

Total

32

Last Release

258d ago

Major Versions

v0.8.0 → v8.0.x-dev2021-09-17

v0.10.1 → v1.0.02025-07-01

PHP version history (3 changes)v0.1.0PHP &gt;=7.1

v0.8.0PHP &gt;=8.0

v1.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f1e4a07705883a7c4150960abc5b005bfc54d36ac2b88642972b3e7d8a470c4?d=identicon)[SonOfWinter](/maintainers/SonOfWinter)

---

Top Contributors

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

---

Tags

php8symfony-bundlesymfony7translationphpsymfonybundletranslation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sonofwinter-translation-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sonofwinter-translation-bundle/health.svg)](https://phpackages.com/packages/sonofwinter-translation-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4362.7M19](/packages/lexik-translation-bundle)[sulu/sulu

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

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

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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