PHPackages                             survos/babel-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. survos/babel-bundle

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

survos/babel-bundle
===================

Lightweight translation base (Str/StrTranslation) + Translatable attribute &amp; subscriber

2.0.182(3mo ago)0841↓25%3MITPHPPHP ^8.4

Since Aug 25Pushed 2mo agoCompare

[ Source](https://github.com/survos/babel-bundle)[ Packagist](https://packagist.org/packages/survos/babel-bundle)[ GitHub Sponsors](https://github.com/kbond)[ RSS](/packages/survos-babel-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (34)Versions (170)Used By (3)

SurvosBabelBundle
=================

[](#survosbabelbundle)

SurvosBabelBundle provides **normalized translation storage** with **runtime locale resolution** using **PHP 8.4 property hooks**.

This bundle is intentionally opinionated and **not plug-and-play**. It is designed for:

- applications with many translatable entities,
- batch translation workflows,
- search indexing per locale,
- avoiding per-entity translation join tables.

If you want “EntityTranslation tables per entity”, this is not that bundle.

---

Core idea (read this first)
---------------------------

[](#core-idea-read-this-first)

Every translatable field has **two representations**:

1. A **persisted backing field** (the source text)
2. A **runtime property hook** (the localized value)

Example:

```
$product->title = 'Chair';     // write source text
echo $product->title;          // read localized text (if available)
```

Only the **backing field** is persisted. The localized value is resolved at runtime.

---

Hard requirements (non-negotiable)
----------------------------------

[](#hard-requirements-non-negotiable)

If you violate any of these, Babel will not work.

### 1. PHP 8.4 property hooks

[](#1-php-84-property-hooks)

This bundle **requires PHP 8.4**.

### 2. BabelHooksInterface **must** be implemented

[](#2-babelhooksinterface-must-be-implemented)

Entities using Babel **must** implement:

```
Survos\BabelBundle\Contract\BabelHooksInterface
```

The easiest way is to use the provided trait:

```
use Survos\BabelBundle\Entity\Traits\BabelHooksTrait;
```

⚠️ The compiler pass relies on this interface. If it is missing, the entity will not be indexed.

### 3. Naming convention is strict

[](#3-naming-convention-is-strict)

For every logical field `foo`:

PurposeNameBacking property`fooBacking`Runtime property`foo`The compiler pass and runtime resolver **assume this naming**.

---

Minimal working example
-----------------------

[](#minimal-working-example)

```
