user2287892
user2287892

Reputation: 83

Language footer menu showing only "English" options - TYPO3

I was able to create different languages to my site, however, on the footer section is showing only English.

I have set up 3 different languages:

UID: 3 = PT-BR
UID: 4 = EN
UID: 5 = ES

See the SS: https://i.sstatic.net/7vGyk.jpg

The translation itself, it is working fine, if I click on the third "English" option, for example, it is showing in Spanish, If I click on the second "English" it is showing in English, if I click on the first, it is showing in Portuguese

If I go to "Constant Editor", the languageValue for SectionLanguage is the following:

page.theme.language.languageValue = 3,4,5

The question is: how can I change the page to show only the languages that I have? PT-BR, English, Spanish. I'm using Bootstrap package for the template and TYPO3 8.7.24

Upvotes: 0

Views: 523

Answers (1)

Riccardo De Contardi
Riccardo De Contardi

Reputation: 2148

If you are using version 8.7.x of TYPO3 I guess you are using also using EXT:bootstrap_package version 8.x

First of all, I think you have already added the following TypoScript code:

[globalVar = GP:L = 3]
    config {
        sys_language_uid = 3
        language = pt
        locale_all = pt_BR.UTF-8
        htmlTag_setParams = lang="pt" dir="ltr" class="no-js"
    }
[global]
[globalVar = GP:L = 4]
    config {
        sys_language_uid = 4
        language = en
        locale_all = en_EN.UTF-8
        htmlTag_setParams = lang="en" dir="ltr" class="no-js"
    }  
[global]
[globalVar = GP:L = 5]
    config {
        sys_language_uid = 5
        language = es
        locale_all = es_ES.UTF-8
        htmlTag_setParams = lang="es" dir="ltr" class="no-js"
    }  
[global]

Second, as far as I can see from the partials inside Bootstrap Package I think you should override EXT:bootstrap_package/Resources/Private/Partials/Page/Navigation/Language.html with something like:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
    <f:if condition="{languagenavigation}">
        <ul id="language_menu" class="language-menu">
            <f:for each="{languagenavigation}" as="item">
                <li class="{f:if(condition: item.active, then: 'active')} {f:if(condition: item.available, else: 'text-muted')}">
                    <f:switch expression="{item.languageUid}">
                        <f:case value="3">
                            <f:variable name="languageTitle">Português Brasileiro</f:variable>
                            <f:variable name="hreflang">pt-BR</f:variable>
                        </f:case>
                        <f:case value="5">
                            <f:variable name="languageTitle">Español</f:variable>
                            <f:variable name="hreflang">es-ES</f:variable>
                        </f:case>
                        <f:defaultCase>
                            <f:variable name="languageTitle">English</f:variable>
                            <f:variable name="hreflang">en-GB</f:variable>
                        </f:defaultCase>
                    </f:switch>
                    <f:if condition="{item.available}">
                        <f:then>
                            <a href="{item.link}" hreflang="{hreflang}" title="{languageTitle}">
                                <span>{languageTitle}</span>
                            </a>
                        </f:then>
                        <f:else>
                            <span>{languageTitle}</span>
                        </f:else>
                    </f:if>
                </li>
            </f:for>
        </ul>
    </f:if>

My opinion is that you always get the "English" label because, using the default partial, you are always stuck inside the <f:defaultCase> part of the switch.

P.S. I used "English" as default, but feel free to adapt everything to your needs.

Upvotes: 1

Related Questions