Reputation: 6158
I try to automaticly set the language in my typo3 6.2 One-Tree Page.
To my setup, I use RealURL to add the langauge to the URL, I use the default L
parameter. I DON'T use ISO codes for the languages, but I use static_info_tables to set the ISO Code. For the language switch I try to use the extention rlmp_language_detection
but it does not work.
My language config (typo3name, Official ISO Code - selected with static_info_tables, ID - used for L
parameter)
My Typoscript for the plugin:
plugin.tx_rlmplanguagedetection_pi1 {
useOneTreeMethod = 1
defaultLang = en
}
My Typoscript for langauges:
config {
sys_language_uid = 0
language = en
locale_all = en-eu
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en-us
}
[global]
[globalVar = GP:L = 2]
config {
sys_language_uid = 2
language = en
locale_all = en-jp
}
[global]
[globalVar = GP:L = 3]
config {
sys_language_uid = 3
language = jp
locale_all = jp-jp
}
[global]
To test it I set my first langauge to japanese and when I request the rootpage this is in my request-header:
Accept-Language:ja,de-DE;q=0.8,de;q=0.6,en-US;q=0.4,en;q=0.2
http://mybrowserinfo.com/ say:
Language:Japanese
System Language:Not detectable with this browser
User Language:de
But no L
Parameter is set at all, so I get the default language.
Upvotes: 3
Views: 3481
Reputation: 736
I've had same problems: How i made it works step by step:
1 Step:
install static_info_tables
be careful it should be in DB utf-8 charsetin latin1 (in my case) don't work
2 Step:
istall rlmp_language_detection
3 Step:
check if on you server installed php-geoip
php module, if not install Ext: ml_geoip
or any way install it.
4 Step
include static templates in your TS template
5 Step
Pls don't forget to choose ISO code of toy lang in base line pages tree
6 Step TS settings - add this after all lang configuration
plugin.tx_rlmplanguagedetection_pi1 {
# this mean that you hav ejust one tree pages for all lang, for multi trees look manual
useOneTreeMethod = 1
#important - this your website sys_language default
defaultLang = ru
# use -1 when you wont to test redirect, after change to 0
cookieLifetime = -1
# you defind which method will be used for redirect browser or ip, better testing just with one
testOrder = browser,ip
# we can config aliases like "code = lang1, lang2"
languageAliases >
languageAliases {
ua = uk,en
en = en
ru = ru,en
}
#we can country codes dependencies "country code = lang"
countryCodeToLanguageCode >
countryCodeToLanguageCode {
ua = uk
us = en
gb = en
nz = en
au = en
ie = en
ca = en
by = ru
}
#this just limit input params array
limitToLanguages = ru,uk,en
}
# ok just after all we include ext to page, on ts begining you shoud to have "page = PAGE" just check
page.1007 = < plugin.tx_rlmplanguagedetection_pi1
Upvotes: 4
Reputation: 9671
I'd suggest using .htaccess to redirect the browser acceptance language. This saves you loading up the whole TYPO3 instance just to do a redirect.
Depending on weather you use realurl it would look something like this:
RewriteCond %{HTTP:Accept-Language} ^en-us [NC]
RewriteRule ^$ /en-us/ [L,R=307]
RewriteCond %{HTTP:Accept-Language} ^ja [NC]
RewriteRule ^$ /jp/ [L,R=307]
RewriteCond %{HTTP:Accept-Language} ^en-gb [NC]
RewriteRule ^$ /en-eu/ [L,R=307]
I don't know how to target en-jp though.
On our websites we use the 307 as status code, so the browser will always look for the initial page (in case the structure changes), also it doesn't affect SEO.
Upvotes: 2