0
votes

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>
2
Can you give more information about how you generate your language menu? Do you use a MenuProcessor in typoscript or something else?StatiX
@StatiX Sure, I've edited my question with the cut down partial of what I use now for rendering my navigation.josias

2 Answers

1
votes

I found the solution I was looking for:

While setting up regular localisation settings, I added some TypoScript configuration from the Localisation documentation. I added the following lines:

# 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]

Using my language IDs of course. That fixed my problem, now the translated page title appears in the title tag and my navigation.

I'm guessing the "sys_language_overlay = 1" option has that purpose.

0
votes

I use typolink to render my a tag like this :

<f:link.typolink parameter="{item.data.uid}" target="{item.target}" title="{item.title}" class="menu-link">{item.title}</f:link.typolink>