1

I am using translatable

It can handle the data directly depending on the current locale setting.

However I want to access each data sometimes with ignoring locale setting.

in contoroller.

I can access each data like this.

    $transRepo = $em->getRepository('Gedmo\Translatable\Entity\Translation');
    $repo = $transRepo->findTranslations($myEntity);
    var_dump($repo['en']['comment']);

Then, is there any way to fetch each language data in twig??

{{comment}} // it shows the comment depending on the locale setting.

{{comment | trancelate(en)}} // I want to ignore the locale setting like this.
whitebear
  • 11,200
  • 24
  • 114
  • 237
  • Are you using "Personal translations" or everything is wrapped up in a single entity? – Artamiel Apr 17 '15 at 20:40
  • I am not sure what the Personal translations means though, I think everything is wrapped in a single entity. I didn't make another entity for my data. There are two tables in my database though, 'myEntity', 'ext_translations'. – whitebear Apr 17 '15 at 21:40

1 Answers1

3

How about passing the translations to your Twig template since you need to show them:

$translations = $repository->findTranslations($article);

And then in your Twig template you could do something like:

{{ translations.en.comment }}
{{ translations.de.comment }}
{{ translations.fr.comment }}

The official documentation might help.

ggioffreda
  • 650
  • 6
  • 11