In the Translatable behaviour of the Gedmo Doctrine Extensions, it has instructions on "Personal Translations". Could someone clarify what personal translations are?
Personal translations are used when you want to handle the translation entity (with it's own table by yourself) instead of the default behaviour, by using a single table for all translations.
By using the default behaviour, you get a single table called ext_translations
which holds all of your translation data. I'll give you an example based on the documentation of DoctrineExtensions
.
Let's say we create an Article
entity with 2 translatable fields - title
and content
. That would mean that we should have the following table structure of articles
:
+----+-------+---------+
| id | title | content |
+----+-------+---------+
Now, by default the TranslatableListener sets en_us
locale every time you create new entity, thus populating only articles
table:
$article = new Article();
$article->setTitle('Title english');
$article->setContent('Content english');
Would lead to the following:
+----+---------------+-----------------+
| id | title | content |
+----+---------------+-----------------+
| 1 | Title english | Content english |
+----+---------------+-----------------+
By now, only articles
get to be updated with new records, but when you want to translate those fields with different locale, our common table ext_translations
get updated as well.
The table has the following structure:
+----+--------+---------------+---------+-------------+------------+
| id | locale | object_class | field | foreign_key | content |
+----+--------+---------------+---------+-------------+------------+
So, what happens when we update our record with some new translations:
$article->setTitle('My title');
$article->setContent('My content');
$article->setTranslatableLocale('de_de');
When we persist our updated entity, we get the following structure in ext_translations
:
+----+--------+---------------+---------+-------------+------------+
| id | locale | object_class | field | foreign_key | content |
+----+--------+---------------+---------+-------------+------------+
| 1 | de_de | Bundle\Entity | title | 1 | My title |
| 2 | de_de | Bundle\Entity | content | 1 | My content |
+----+--------+---------------+---------+-------------+------------+
Now you know how the default behaviour works. It stores all of your translations (not just for single entity, all of them) in a single table.
But when you're using a personal translations you can store your (let's say for the sake of our example) Article
translations to its own, separate table, article_translations
.
If you are familiar with DoctrineExtensions
provided by KnpLabs
, then you've already seen what stands for PersonalTranslations
. Link for their documentation about this subject can be found here.
Well hopes this can clarify things a bit for you. Let me know if you have more questions about this.