简体   繁体   English

Typo3 Extbase 中的翻译不适用于内联关系

[英]Typo3 Translations in Extbase not working with inline relations

i created an extension which uses a main controller which could add inline relations.我创建了一个使用主 controller 的扩展,它可以添加内联关系。 I`m using Typo3 11.我正在使用 Typo3 11。

If I translate the relations, but not the main Entry, also the language of the already translated relation is the default one.如果我翻译关系,而不是主条目,那么已经翻译的关系的语言也是默认语言。

It doesnt matter, if i set the language to "all", the result is still the same.没关系,如果我将语言设置为“全部”,结果仍然是一样的。 I really have to translate the main entry to the other language althought its not necessary.我真的必须将主要条目翻译成另一种语言,尽管这不是必需的。

Is there a way to resolve this issue?有没有办法解决这个问题?

There is a simple rule of thumb: Only use language "all" for parent elements that contain only child elements which should be visible in "all" languages too.有一个简单的经验法则:仅对仅包含子元素的父元素使用“所有”语言,这些子元素也应该在“所有”语言中可见。

As soon as there should be translated children, you should translate the parent element first and usually pick "connected mode", which will give the default language the lead over the target language behaviour.一旦应该有翻译的子元素,您应该首先翻译父元素并且通常选择“连接模式”,这将使默认语言领先于目标语言行为。

If there are differences between the number of different child elements and/or there are child elements in a target language, which don't exist in the default language, you should go for "free mode" translations instead.如果不同子元素的数量存在差异和/或目标语言中存在默认语言中不存在的子元素,则您应该使用 go 进行“自由模式”翻译。

So actually there is no "although its not necessary" in your case.所以实际上在你的情况下没有“虽然它没有必要”。

I dont know the reason why, but if I integrated a "foreach" over my "missingTranslationArray" inline IRRE, at the top of my Template the translation is shown.我不知道为什么,但是如果我在我的“missingTranslationArray”内联 IRRE 上集成了一个“foreach”,就会在我的模板顶部显示翻译。 It doesnt matter that the foreach doesn't make sense inside my template, but now the missing translations are shown. foreach 在我的模板中没有意义并不重要,但现在显示了缺少的翻译。

<f:for each="{myMissingTranslations}" as="myMissingTranslation"></f:for>

For me that helps, but i have no answer why its necessary.对我来说这有帮助,但我不知道为什么有必要。

For all who have the same problem, now I`ve got a solution.对于所有遇到同样问题的人,现在我有了解决方案。

Rewrite the "showAction" inside the controller like:重写 controller 中的“showAction”,如:

From:从:

/**
 * action show
* 
 * @param \VENDOR\myExtension\Domain\Model\controller $controller
 * @return void
 */
public function showAction(\VENDOR\myExtension\Domain\Model\controller $controller)
{

To:到:

 /**
 * action show
 * 
 * @return void
 */
public function showAction()
{

And submit just the "uid".并只提交“uid”。 Inside the controller use the "findbyuid" repository for the entry.在 controller 内部,使用“findbyuid”存储库作为条目。

$id = $this->request->getArguments('entry');
$entry = $this->entryRepository->findByUid($id['entry']); 
$this->view->assign('entries', $entry);  

The empty repository for each inside the template is also necessary.模板内每个的空存储库也是必需的。 For that renders every repository inside every single action.为此,在每个动作中呈现每个存储库。

ie: IE:

<f:for each="{myRelation1}" as="myRelation1"></f:for>
<f:for each="{myRelation2}" as="myRelation2"></f:for>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM