in translatable behaviour of gedmo doctrine extensions, has instructions on "personal translations". clarify personal translations are?
tl;dr
personal translations used when want handle translation entity (with it's own table yourself) instead of default behaviour, using single table translations.
by using default behaviour, single table called ext_translations holds of translation data. i'll give example based on documentation of doctrineextensions.
let's create article entity 2 translatable fields - title , content. mean should have following table structure of articles:
+----+-------+---------+ | id | title | content | +----+-------+---------+ now, default translatablelistener sets en_us locale every time create new entity, populating articles table:
$article = new article(); $article->settitle('title english'); $article->setcontent('content english'); would lead following:
+----+---------------+-----------------+ | id | title | content | +----+---------------+-----------------+ | 1 | title english | content english | +----+---------------+-----------------+ by now, articles updated new records, when want translate fields different locale, our common table ext_translations updated well.
the table has following structure:
+----+--------+---------------+---------+-------------+------------+ | id | locale | object_class | field | foreign_key | content | +----+--------+---------------+---------+-------------+------------+ so, happens when update our record new translations:
$article->settitle('my title'); $article->setcontent('my content'); $article->settranslatablelocale('de_de'); when persist our updated entity, following structure in ext_translations:
+----+--------+---------------+---------+-------------+------------+ | id | locale | object_class | field | foreign_key | content | +----+--------+---------------+---------+-------------+------------+ | 1 | de_de | bundle\entity | title | 1 | title | | 2 | de_de | bundle\entity | content | 1 | content | +----+--------+---------------+---------+-------------+------------+ now know how default behaviour works. stores of translations (not single entity, of them) in single table.
but when you're using personal translations can store (let's sake of our example) article translations own, separate table, article_translations.
if familiar doctrineextensions provided knplabs, you've seen stands personaltranslations. link documentation subject can found here.
well hopes can clarify things bit you. let me know if have more questions this.
Comments
Post a Comment