本文介绍了gedmo原则可翻译延伸。检索所有翻译或特定的翻译(与当前语言环境不同)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体,使用gedmo的学说可翻译扩展。
我可以在当前语言环境中加载该实体。



现在,对于希望用户查看和编辑各种翻译的管理面板,我想显示所有翻译或用户选择的特定翻译。



我在该实体上只有 - > getTranslations方法。加载精选翻译还有另一个窍门?
给定方案有最佳做法吗?



非常感谢!

解决方案

我解决了从实体翻译存储库检索翻译,并传递给表单模型(我创建的模型来处理翻译):

  $ nodeRepository = $ this-> getDoctrine() - > getRepository('AcmeCoreBundle:Node'); 
$ node = $ repository-> find($ id);

$ translationsRepository = $ this-> getDoctrine()> getRepository('Acme\CoreBundle\Entity\NodeTranslation');

//检索给定节点的翻译
$ translations = $ repository-> findTranslations($ node);

$ model = new TranslatableModel($ node,$ translations,...);

我希望这可以帮助某人...



Ciao


I've an entity that uses gedmo doctrine translatable extension.I'm able to load this entity in the current locale.

Now, for an admin panel where I want users to see and edit the various translations, I want to show all the translations or a specific one chosen by the user.

I just have the ->getTranslations method on that entity. There's another trick to load just the select translation?Is there any best practice for the given scenario?

Thanks a lot!

解决方案

I solved this retrieving the translations from the entity "Translation Repository" and passing to the Form Model (a model i created to handle the translations):

$nodeRepository = $this->getDoctrine()->getRepository('AcmeCoreBundle:Node');
$node = $repository->find($id);

$translationsRepository = $this->getDoctrine()>getRepository('Acme\CoreBundle\Entity\NodeTranslation');

// retrieving the translations for the given node
$translations = $repository->findTranslations($node);

$model = new TranslatableModel($node, $translations, ...);

I hope this would help someone...

Ciao

这篇关于gedmo原则可翻译延伸。检索所有翻译或特定的翻译(与当前语言环境不同)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 15:58