Setting a multilanguage site in TYPO3 - typo3

I'm trying to set up a multilanguage site with typo3, but Im having some trouble. The default language of the site is German, but I also want to have it in English and French. So I went to define 2 more languages: English with ID=2 and French with ID=3
Next I added this typoscript to my template:
config.linkVars = L
config.uniqueLinkVars = 2
config.sys_language_overlay = content_fallback
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de-DE
config.sys_language_uid = 0
[globalVar = GP:L = 2]
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en-EN
config.sys_language_uid = 2
[globalVar = GP:L = 3]
config.language = fr
config.sys_language_uid = 3
config.locale_all = fr_FR
config.htmlTag_langKey = fr-FR
[end]
And then I added this language menu, from the extension srlanguagemenu:
10 < plugin.tx_srlanguagemenu_pi1
10{
languagesUidsList = 0,2,3
defaultLayout = 2
showLinkWithFlag = 0
showCurrent = 1
}
But the menu only shows "English". This is the exact markup:
<div class="tx-srlanguagemenu-pi1">
<div class="CUR"><img src="typo3/gfx/content_client.gif" alt="" style="width:7px; height:10px;">English</div>
<div class="SPC"> </div> <div class="INACT"></div>
<div class="SPC"> </div> <div class="INACT"></div>
</div>
Also. In the menu, the name of the pages doesn't show the translated version.
What am I doing wrong?

You need to translate not only the content of your page, but also the page. This is done via creating an "alternative_page_language" ("alternative Seitensprache" in german).
You can create an multilanguage TS menu via HMENU.special = language.
For working with translations, have a look at the INFO-Modul. There is a "Localization Overview", don't miss it:) I guess you already found the language View in the Page Modul.

Related

Typo3 vhs language returns id instead of language

I try to setup a language menu with 3 different languages. For english and german its working. It shows the current language either as EN or DE. But when i switch to italian, it only shows the id (7) in the frontend.
My Code is:
{v:page.language(languages: 'EN,DE,IT', pageUid: '0', normalWhenNoLanguage: 'EN')
Lanugage setup:
[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 = fr
locale_all = fr_FR.UTF-8
htmlTag_setParams = lang="fr" dir="ltr" class="no-js"
}
[global]
[globalVar = GP:L = 7]
config {
sys_language_uid = 7
language = it
locale_all = it_IT.UTF-8
htmlTag_setParams = lang="it" dir="ltr" class="no-js"
}
[global]
If the id is 7 and your array of languages only contains three elements, what do you expect?
The VH does not access the TS configuration. It can't as the VH can not influence conditions to select the 'requested' language. So it only can access the current language configuration.
The 8th element of three elements (= your first parameter to this VH: the array with the 2 character language codes) would be out of range and should not be accessed (and if you do as it is possible in some languages you get an security issue).

Typo3 CMS 8.7.15 // restrict search results to current language

I'm using the TYPO3 version TYPO3 CMS 8.7.15. with a multilanguage setup. Everything works fine. German is the default language. The other configured languages are english, portugeese and chinese. The problem is when I try to search keywords in different languages than the current language, i get results from the other translations. I want to ask for the right settings to display only search results in the current language from the current content.
config {
linkVars = L
uniqueLinkVars = 1
sys_language_mode = content_fallback
sys_language_overlay = 1
sys_language_uid = 0
locale_all = de_DE.UTF-8
htmlTag_langKey = de
language = de
}
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 0
# SPRACHE: ENGLISCH
[globalVar = GP:L=6]
config {
sys_language_uid = 6
language = en
locale_all = en_GB.UTF-8
htmlTag_setParams = en
}
pugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 6
[global]
# SPRACHE: PORTUGIESISCH
[globalVar = GP:L=7]
config {
sys_language_uid = 7
language = pt
locale_all = pt_PT.UTF-8
htmlTag_setParams = pt
}
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 7
[global]
# SPRACHE: CHINESISCH (EINFACH)
[globalVar = GP:L=8]
config {
sys_language_uid = 8
language = zh
locale_all = zh_CN.UTF-8
htmlTag_setParams = zh
}
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 8
[global]
The only way to configure it right is the plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang variable. But this has no effect to my search results. What is wrong with my configuration?
If you put your search field into your menu for example (fluidtemplate) the <f:form.hidden name="search[languageUid]"is not filled. So the results shows all languages.
I helped myself by using a lib that gives me the current language.
Fluid:
<f:form.hidden name="search[languageUid]" value="{f:cObject(typoscriptObjectPath: 'lib.language')}" />
Typoscript Setup:
# German language
temp.language = TEXT
temp.language.value = 0
# English language
[globalVar = GP:L = 1]
temp.language.value = 1
[global]
lib.language < temp.language

In TYPO3, using RealURL, how do translated URLs work

I have added an HMENU of type language, and some translations, and I can click the menu buttons to see the translations. However, there are a few things which are broken, and I'd like to get a more fundamental understanding.
The first thing which is strange: in the language menu the HREF for untranslated pages looks like e.g. /en/my-page, whereas the HREF for translated pages looks like /my-page?L=1. Wbat's going on here? I've put in the preVars section described in https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#configuring-languages. I would prefer it if the user never had to see the ?L=x query string parameter.
Edit: I have fixed this first issue by correcting my domain record from https://www.my.domain.com to www.my.domain.com, then clearing out the realurl database tables.
My second problem is my other normal HMENUs. The text in these is getting translated correctly, but the links are not - you end up going back to the default language every time you navigate.
Any help much appreciated.
I have tried all of the following:
'Clear all cache' button
'Clear PHP opcode cache' button
rm -rf /var/www/typo3temp/*
Delete contents of all the tx_realurl tables in the database
My TypoScript:
config.doctype = html5
config.absRefPrefix = /
config.tx_realurl_enable = 1
## config.sys_language_overlay = 1 # I don't actually know what this does!
config.linkVars = L(0-9) # Make the language link variables work.
## Defaults
config.language = en
config.locale_all = en_GB.utf8
config.htmlTag_langKey = en-GB.utf8
config.sys_language_uid = 0
[globalVar = GP:L = 1]
config.language = da
config.locale_all = da_DA.utf8
config.htmlTag_langKey = da-DA.utf8
config.sys_language_uid = 1
[globalVar = GP:L = 2]
config.language = de
config.locale_all = de_DE.utf8
config.htmlTag_langKey = de-DE.utf8
config.sys_language_uid = 2
## There's no 3
[globalVar = GP:L = 4]
config.language = es
config.locale_all = es_ES.utf8
config.htmlTag_langKey = es-ES.utf8
config.sys_language_uid = 4
## There's no 5
[globalVar = GP:L = 6]
config.language = lv
config.locale_all = lv_LV.utf8
config.htmlTag_langKey = lv-LV.utf8
config.sys_language_uid = 6
[globalVar = GP:L = 7]
config.language = ro
config.locale_all = ro_RO.utf8
config.htmlTag_langKey = ro-RO.utf8
config.sys_language_uid = 7
[globalVar = GP:L = 8]
config.language = pl
config.locale_all = pl_PL.utf8
config.htmlTag_langKey = pl-PL.utf8
config.sys_language_uid = 8
[globalVar = GP:L = 9]
config.language = pt
config.locale_all = pt_PT.utf8
config.htmlTag_langKey = pt-PT.utf8
config.sys_language_uid = 9
[END]
## Language Menu
lib.language_menu = HMENU
lib.language_menu {
special = language
special.value = 0,1,2,4,6,7,8,9
1 = TMENU
1 {
wrap = <ul class="language-menu">|</ul>
noBlur = 1
NO = 1
NO {
linkWrap = <li>|</li>
stdWrap.override = En || Da || De || Es || Lv || Ro || Pl || Pt
}
ACT < .NO
ACT {
linkWrap = <li class="active">|</li>
}
# NO + Translation doesn't exist
USERDEF1 < .NO
# USERDEF1.doNotLinkIt = 1
# ACT + Translation doesn't exist
USERDEF2 < .ACT
# USERDEF2.doNotLinkIt = 1
}
}
You need to set config.linkVars to keep the language GET parameter in all links: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#linkvars
Example (if you only have two languages):
config.linkVars = L(0-1)
if realUrl does not render links like
/<lng>/mypage.html and only mypage.html?L=<2>
check the path to your realurl config file, /see extension manager -> real Url -> setings where realurl is looking for it
check settings in extension manager realurl : is autoconfig enabled ?
check the domain settings records (sometimes rearl needs a domain
record set)
check if the page with documentroot has the setting is document Root (helps realurl to generate a working realUrl autoconfig.
if you start from scratch with realurl, removing the autogenerated realurl config file, disable the extension and enablerealurl again sometimes helps after fixing bugs.

Typo3 backend not multilanguest

In typoscript I have setup my website to support three languages. In the frontend it is working fine but in the backend i'm missing the dropdown selection for "languages"? Only "Columns" and "Quickedit" are visible. How can i enable the "languages" selection in the BE?
I used this typoscript to set it up:
page.config.linkVars = L
page.config.uniqueLinkVars = 1
page.config.sys_language_overlay = content_fallback
page.config.language = nl
page.config.locale_all = nl_NL
page.config.htmlTag_langKey = nl-NL
page.config.sys_language_uid = 0
[browser = msie]
page.config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml" xmlns:v=”urn:schemas-microsoft-com:vml” xml:lang="nl"
[globalVar = GP:L = 1]
page.config.language = en
page.config.locale_all = en_EN
page.config.htmlTag_langKey = en-EN
page.config.sys_language_uid = 1
[globalVar = GP:L = 1] && [browser = msie]
page.config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml" xmlns:v=”urn:schemas-microsoft-com:vml” xml:lang="en"
[globalVar = GP:L = 2]
page.config.language = de
page.config.locale_all = de_DE
page.config.htmlTag_langKey = de-DE
page.config.sys_language_uid = 2
[globalVar = GP:L = 2] && [browser = msie]
page.config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml" xmlns:v=”urn:schemas-microsoft-com:vml” xml:lang="de"
In Order to be able to translate content in the backend into e.g. english you need to
Go to your Root page (ID=0), select the list module and create a
'Website Language' Record 'english'.
Go to the page you want to translate and create a record called
'Alternative Page Language'. Choose 'english' as Language.
You should now see a translation option in the discribed dropdown.
Repeat for as many pages and languages as you need.
Edit: You can see how this is done in this (german) video: http://www.youtube.com/watch?v=62ZuTYRKq5U

Language Switcher TYPO3

I'm trying to create a language switch with personal images that makes possible to change the website language in the frontend (I already defined the languages and the alternative language pages). I'm using a snippet from TYPO3 Core Documentation, but it's not working for me, so I must be doing something wrong...I added a marker in my template called LANGUAGE, which corresponds to a DIV in the top right corner of the main container, where would appear some representative flags of the languages available for that page.
Here it is my TS code in the Template:
config.linkVars = L , type
config.sys_language_uid = 0
config.language = en
config.locale_all = en_EN
[globalVar = GP:L =0]
config.sys_language_uid = 0
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
[global]
[globalVar = GP:L =1]
config.sys_language_uid = 1
config.language = pt
config.locale_all = pt_PT
config.htmlTag_langKey = pt
[global]
[globalVar = GP:L =2]
config.sys_language_uid = 2
config.language = fr
config.locale_all = fr_FR
config.htmlTag_langKey = fr
[global]
[globalVar = GP:L =3]
config.sys_language_uid = 3
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
[global]
page.10.marks.LANGUAGE {
lib.langMenu = HMENU
lib.langMenu {
special = language
special.value = 0,1,2,3
special.normalWhenNoLanguage = 0
1 = GMENU
1.NO {
XY = [5.w]+4, [5.h]+4
backColor = white
5 = IMAGE
5.file = fileadmin/Template/images/english.png || fileadmin/Template/images/portuguese.png || fileadmin/Template/images/french.png || fileadmin/Template/images/german.png
5.offset = 2,2
}
}
}
Yes, this can't work because you're defining a lib element inside a mark. You must nest your code differently:
lib.langMenu = HMENU
lib.langMenu {
[all your stuff from the lang menu]
}
and then
page.10.marks.LANGUAGE < lib.langMenu
By the way, if you also define the states USERDEF1 and USERDEF2 and use doNotShowLink = 1, then the link to a language isn't rendered if the page is not available in this language. This can be very helpful when not all your content is translated and you don't want to use fallback:
USERDEF1 = 1
USERDEF1.doNotShowLink = 1
USERDEF2 < .USERDEF1