0

I'm working on a page with multi language support. I've managed to get it to work with realurl and the backend.

Now I'm not quite sure how to render the translated text from the backend.

For instance: I have a page in the default language (en) with the title "Contact". Now I have created a translation in german with the title "Kontakt".

With my configuration my url now says:

  • en: domain.com/en/contact
  • de: domain.com/de/kontakt

But my navigation rendered with a fluid template still shows the default language even on the german url. Is there a variable for {page.title.currentLanguage} or something like that?

Of course I could create a translation inside a locallang.xlf file but in order to use the f:translate viewhelper, but that would mean I have to translate the page's name twice, right?

I appreciate all the help!

My current partial for rendering the navigation:

<nav>
    <div class="container">
        <ul class="content btns">
            <f:for each="{mainnavigation}" as="mainnavigationItem">
                <li class="{f:if(condition: mainnavigationItem.active, then:'active')}">
                    <a href="{mainnavigationItem.link}" target="{mainnavigationItem.target}" title="{mainnavigationItem.title}">{mainnavigationItem.title}</a>
                    <f:if condition="{mainnavigationItem.children}">
                        <ul>
                            <f:for each="{mainnavigationItem.children}" as="child">
                                <li class="{f:if(condition: child.active, then:'active')}">
                                    <a href="{child.link}" target="{child.target}" title="{child.title}">{child.title}</a>
                                </li>
                            </f:for>
                        </ul>
                    </f:if>
                </li>
            </f:for>
        </ul>
    </div>
</nav>
4

2 回答 2

1

我找到了我正在寻找的解决方案:

在设置常规本地化设置时,我从本地化文档中添加了一些TypoScript 配置。我添加了以下几行:

# Localization:
config {
        linkVars = L(int)
        sys_language_uid = 0
        sys_language_overlay = 1
        sys_language_mode = content_fallback
        language = en
        locale_all = en_US.UTF-8
        htmlTag_setParams = lang="en" dir="ltr" class="no-js"
}
[globalVar = GP:L = 1]
        config {
                sys_language_uid = 1
                language = de
                locale_all = de_DE.UTF-8
                htmlTag_setParams = lang="de" dir="ltr" class="no-js"
        }
[global]
[globalVar = GP:L = 2]
        config {
                sys_language_uid = 2
                language = da
                locale_all = da_DK.UTF-8
                htmlTag_setParams = lang="da" dir="ltr" class="no-js"
        }
[global]

当然使用我的语言 ID。这解决了我的问题,现在翻译的页面标题出现在标题标签和我的导航中。

我猜“sys_language_overlay = 1”选项有这个目的。

于 2018-06-13T08:56:45.417 回答
0

我使用typolink来呈现我的标签,如下所示:

<f:link.typolink parameter="{item.data.uid}" target="{item.target}" title="{item.title}" class="menu-link">{item.title}</f:link.typolink>
于 2018-06-08T07:22:34.813 回答