2015-04-17 28 views
1

我使用translatable如何在樹枝打印翻譯值(教義擴展)

它可以處理直接根據當前的區域設置的數據。

但是我想在忽略區域設置的情況下訪問每個數據。

in contoroller。

我可以像這樣訪問每個數據。

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

那麼,有沒有什麼辦法來獲取每個語言的數據在樹枝?

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

{{comment | trancelate(en)}} // I want to ignore the locale setting like this. 
+0

你使用「個人翻譯」還是一切都包含在一個單一的實體? – Artamiel

+0

雖然我不確定個人翻譯的含義,但我認爲所有內容都包含在一個實體中。我沒有爲我的數據創建另一個實體。我的數據庫中有兩個表,'myEntity','ext_translations'。 – whitebear

回答

2

如何通過翻譯你的枝杈模板,因爲你需要告訴他們:

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

,然後在枝條的模板,你可以這樣做:

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

official documentation可能會有所幫助。

+0

現在,它可以解決問題。 – whitebear