Language Switcher TYPO3 - 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

Related

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.

Setting up a TYPO3 page as multilingual page

I've got a TYPO3 page which is only in german. Now I want to set up the page in english as well. How can I realise this? I've read about webpage language and so on but, can't find a whole tutorial.
I'm using TYPO3 6.2.9
Thanks a lot
Update
## Localization menu:
lib.langMenu = HMENU
lib.langMenu {
special = language
special.value = 0,1,2
special.normalWhenNoLanguage = 0
1 = GMENU
1.NO {
XY = [5.w]+4, [5.h]+4
backColor = white
5 = IMAGE
5.file = EXT:cms/tslib/media/flags/flag_uk.gif || EXT:cms/tslib/media/flags/flag_de.gif
5.offset = 2,2
}
1.ACT < lib.langMenu.1.NO
1.ACT=1
1.ACT.backColor = black
1.USERDEF1 < lib.langMenu.1.NO
1.USERDEF1=1
1.USERDEF1.5.file = EXT:cms/tslib/media/flags/flag_uk.gif || EXT:cms/tslib/media/flags/flag_de.gif
1.USERDEF1.noLink = 0
1.USERDEF2 < lib.langMenu.1.USERDEF1
1.USERDEF2.backColor = green
}
Well,
in TYPO3 it is really easy to set up an other Language
All you need to do ist:
Create on your rootpage (the world) a new lanuguage
Then add in your Setup on the rootpage the following (for example french)
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = fr
config.locale_all = fr_FR
[global]
Then translate your first page.
You can access the page with this link.
Hope it helps.

typo3 templavoila check current language

Hi i have 4 languages in my typo. Here is my main configuration for them:
#LANGS
config.linkVars=L
config.defaultGetVars.L = 0
config.sys_language_overlay = hideNonTranslated
[globalVar = GP:L = 3]
config.sys_language_uid = 3
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3
[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = ro
config.locale_all = ro_RO
config.htmlTag_langKey = ro
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 2
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 1
[global]
All works fine.
Im using templavoila and realurl.
In one of templates/modules/flexible content i have typoscript displays field only when its not empty:
10 = TEXT
10.field = field_test
10.wrap = info: |
10.if.isTrue.field = field_test
Now i'd like to display this field in diferent versions:
like:
10.wrap = informationen |
for DE language etc.
How may i check here what current language is?
Using translation labels in TypoScript
You can use a translation label in TypoScript. For example:
{LLL:typo3conf/customlabels.xlf:label.id}
{LLL:EXT:mytemplateext/Resources/Private/Language/locallang.xlf:label.id}
You may want to look at:
http://docs.typo3.org/typo3cms/FrontendLocalizationGuide/BasicSetupOfALocalizedWebsite/Llxml%28locallang-xml%29InPluginsAndTyposcript/Index.html
llXML files are XML files containing labels that the system can fetch in a localized version if a language pack is installed. If you want to retrieve values from llXML files in TypoScript you can do it like this:
page.20 = TEXT page.20.stdWrap.data =
LLL:EXT:indexed_search/pi/locallang.xml:submit_button_label
And see also:
http://docs.typo3.org/typo3cms/CoreApiReference/Internationalization/Introduction/Index.html
http://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/Localization/Locallang-xml%28llxml%29Files/Index.html
TypoScript variables
You can extend your language configuration with your own settings. For example:
#LANGS
config.linkVars=L
config.defaultGetVars.L = 0
config.sys_language_overlay = hideNonTranslated
myLanguageLabels {
info = info
}
[globalVar = GP:L = 3]
config.sys_language_uid = 3
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
myLanguageLabels {
info = info 2
}
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3
[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = ro
config.locale_all = ro_RO
config.htmlTag_langKey = ro
myLanguageLabels {
info = info 3
}
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 2
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 1
myLanguageLabels {
info = info 3
}
[global]
And then just point out to the variable you want to use:
10.wrap = {$myLanguageLabels.info}: |

TYPO3 4.5 - Multilingual - How can I use the second Language as default?

how can I set my 'second' language at my TYPO3 Website (4.5.x) to default?
I have ID0 = german, ID1 = english and ID2 = spanish
At the moment, if there's no translation TYPO3 will show the default language (0=german)
Here's my TS
# multilingual
##################
config.linkVars = L
config.uniqueLinkVars = 1
# no translation go to default
config.sys_language_mode = content_fallback
# not translated elements, show default
config.sys_language_overlay = 1
#config.sys_language_overlay = hideNonTranslated
# German / default :
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE.UTF8
# English :
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = en
config.locale_all = en_EN.UTF8
config.htmlTag_langKey = en
[global]
# Spanish :
[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = es
config.locale_all = es_ES.UTF8
config.htmlTag_langKey = es
[global]
the solution for your problem is the attribute sys_language_mode
You can define the fallback for each language.
For example in your case
[globalVar = GP:L2]
config {
sys_language_uid = 2
language = es
locale_all = es_ES.UTF-8
htmlTag_langKey = es
sys_language_mode = content_fallback;1,0
}
[global]
This setup the content_fallback followed by the ordering of language_uid that should be used for fallback.
For detailed documentation read the TSREF
http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#sys-language-mode
Cheers
Christian