DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
EXT: Language Selection based on domain¶
Author: | Robert Lemke |
---|---|
Created: | 2005-12-29T13:42:27 |
Changed by: | Jose Guerra |
Changed: | 2007-06-13T19:59:24 |
Email: | jaguerra@icti.es |
Info 2: | |
Info 3: | |
Info 4: |
EXT: Language Selection based on domain¶
Extension Key: icti_language_on_domain
Copyright 2007, jaguerra@icti.es, <jaguerra@icti.es>
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
The content of this document is related to TYPO3
- a GNU/GPL CMS/Framework available from www.typo3.com
Table of Contents¶
EXT: Language Detection 1
Introduction 1
What does it do? 1
Configuration 1
One-Tree vs. Multiple-Trees concept 1
Installation 1
Using the One-Tree concept with TYPO3 2
Using the One-Tree concept with TYPO3 version 3.6.0 or later 2
Defining the default language 2
Doing it with multiple page trees 2
TypoScript Reference 2
FAQ 3
Known problems 3
Changelog 3
Appendix A 3
Introduction¶
Thanks¶
This extension is a little variation of “rlmp_language_detection” written by Robert Lemke. Actually this extension is using 99% of code and documentation from the Robert's one, so please thank and support him instead than me if you feel in need of.
What does it do?¶
This small extension allows to automatically select a language based on the website domain name (HTTP_HOST).
This is so useful if you have a multilingual website with more than one domain name and you'd like to select the default language depending on the domain the user is using on its browser.
In case that a domain/language match the current page will be reloaded and the appropriate language will be set by using the "L" parameter.
Alternatively the multiple-tree concept for multi-langual websites may be used. In that case the visitor will be redirected to a certain page which acts as an entry page for the preferred language.
Configuration¶
One-Tree vs. Multiple-Trees concept¶
While creating multi-lingual websites with TYPO3 generally you have two ways to do that:
- either create one page tree which contains a single page for each language, i.e. using TYPO3's language overlay concept
- or create multiple page trees, one for each language. In this case you want the visitor to start at different pages depending on the preferred language.
Installation¶
Installing this extension is fairly easy. Just download it via the extension manager (EM) and click on the install button.
Using the One-Tree concept with TYPO3¶
There's (almost) no configuration necessary! The only things you'll have to take into account are the titles of your supported languages. Let's see how it works:
You create your website's languages just as normal, but instead of choosing a descriptive title like "english" or "german" you'll have to use the two-letter country codes defined in ISO 3166 (see Appendix A for a full list).
You only have to define the addtitional languages, your default language (L=0) will be used whenever no other language seems to fit. So if your website provides german, english and spanish, your website languages list might look as follows:
Select a language's domain defaults¶
There's an extra field in the “sys_language” table that allows to select the domains for which the language will be default:
In this case, when a user hits “ http://es.typo3.org ”, the Spanish language will be selected automatically (if es.typo3.org resolves and is configured on your TYPO3 site, of course).
You can write more than one domain name, separated by commas.
Using the One-Tree concept with TYPO3 version 3.6.0 or later¶
If you have the table static_languages installed (which you should if you're running TYPO3 3.6.0 or later), it's even one step easier: You don't have to care about the language's title, just choose the right ISO code instead (as you can see in the next screenshot):
Defining the default language¶
You should define which language is your default language, ie. the ISO code of the language which will be shown with the parameter L set to zero. See the TypoScript Reference below how to set the default language.
Doing it with multiple page trees¶
So you need different structures for each language? Then you will likely choose the multiple page tree method (this method is explained on this page at typo3.org ).
In order to enable it, you'll have to add some TypoScript to the setup field of your root template. Just have a look at the example:
plugin.tx_rlmplanguagedetection_pi1 {
useOneTreeMethod = 0
multipleTreesRootPages {
de = 216
en = 120
es = 482
}
}
First you disable the One-Tree-Method by setting useOneTreeMethod = 0. Then you define the unique ids of those pages being the root page for each language.
In our example visitors who prefer spanish will automatically guided to the page with the id 482 if they enter the website.
TypoScript Reference¶
useOneTreeMethod¶
Property
useOneTreeMethod
Data type
boolean
Description
If true, the One-Tree-Method will be used, otherwise the Multiple- Trees concept is chosen.
See the manual for more information about these two concepts.
Default
1
multipleTreesRootPages¶
Property
multipleTreesRootPages
Data type
array of isocodes
Description
When using the Multiple-Trees-Method, you have to define the different languages which are available throughout your website. You do that by using isocodes for the languages and pointing them to the appropriate page id.
Example:
...
multipleTreesRootPages {
de = 216
en = 120
es = 482
}
Default
defaultLang¶
Property
defaultLang
Data type
string
Description
Set this to the ISO code of your default language (L=0)
plugin.tx_rlmplanguagedetection_pi1 {
defaultLang = de
}
Default
dontAddSchemeToURL¶
Property
dontAddSchemeToURL
Data type
boolean
Description
When the URI is built for redirecting to a different page, the URL is parsed through a function which adds the correct scheme. I.e. 246.0.html?L=1 will be transformed to http://yourhost.com/246.0.html?L=1 .
This behavior makes sense of course, but you might have a certain enviroment (some testing setup) where you want to disable this feature. In that case, set dontAddSchemeToURL to 1.
For most people it's safe to leave setting as is.
Default
0
Known problems¶
None at the moment
Appendix A¶
((generated))¶
ISO 3166 two-digit country codes¶
AfghanistAfghanistan¶
Country
AfghanistAfghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Australia
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bermuda
Bhutan
Bolivia
Bosnia and Herzegowina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Canada
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Congo
Congo, The Democratic Republic of the
Cook Islands
Costa Rica
Cote D'ivoire
Croatia (local name: Hrvatska)
Cuba
Cyprus
Czech Republic
Code
AF
AL
DZ
AS
AD
AO
AI
AQ
AG
AR
AM
AW
AU
AT
AZ
BS
BH
BD
BB
BY
BE
BZ
BJ
BM
BT
BO
BA
BW
BV
BR
IO
BN
BG
BF
BI
KH
CM
CA
CV
KY
CF
TD
CL
CN
CX
CC
CO
KM
CG
CD
CK
CR
CI
HR
CU
CY
CZ
Denmark¶
Country
Denmark
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
France, Metropolitan
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guinea
Guinea-Bissau
Guyana
Haiti
Heard and Mc Donald Islands
Holy See (Vatican City State)
Honduras
Hong Kong
Hungary
Iceland
India
Indonesia
Iran (Islamic Republic of)
Iraq
Ireland
Israel
Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Democratic People's Republic of
Korea, Republic of
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Libyan Arab Jamahiriya
Liechtenstein
Lithuania
Luxembourg
Code
DK
DJ
DM
DO
TP
EC
EG
SV
GQ
ER
EE
ET
FK
FO
FJ
FI
FR
FX
GF
PF
TF
GA
GM
GE
DE
GH
GI
GR
GL
GD
GP
GU
GT
GN
GW
GY
HT
HM
VA
HN
HK
HU
IS
IN
ID
IR
IQ
IE
IL
IT
JM
JP
JO
KZ
KE
KI
KP
KR
KW
KG
LA
LV
LB
LS
LR
LY
LI
LT
LU
Macau¶
Country
Macau
Macedonia, The Former Yugoslav Republic of
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States of
Moldova, Republic of
Monaco
Mongolia
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
Northern Mariana Islands
Norway
Oman
Pakistan
Palau
Palestinian Territory, occupied
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Code
MO
MK
MG
MW
MY
MV
ML
MT
MH
MQ
MR
MU
YT
MX
FM
MD
MC
MN
MS
MA
MZ
MM
NA
NR
NP
NL
AN
NC
NZ
NI
NE
NG
NU
NF
MP
NO
OM
PK
PW
PS
PA
PG
PY
PE
PH
PN
PL
PT
PR
QA
RE
RO
RU
RW
Saint Kitts and Nevis¶
Country
Saint Kitts and Nevis
Saint Lucia
Saint Vincent and the Grenadines
Samoa
San Marino
Sao Tome and Principe
Saudi Arabia
Senegal
Seychelles
Sierra Leone
Singapore
Slovakia (Slovak Republic)
Slovenia
Solomon Islands
Somalia
South Africa
South Georgia and the South Sandwich Islands
Spain
Sri Lanka
St. Helena
St. Pierre and Miquelon
Sudan
Suriname
Svalbard and Jan Mayen Islands
Swaziland
Sweden
Switzerland
Syrian Arab Republic
Taiwan
Tajikistan
Tanzania, United Republic of
Thailand
Togo
Tokelau
Tonga
Trinidad and Tobago
Tunisia
Turkey
Turkmenistan
Turks and Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United Kingdom
United States
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Venezuela
Viet Nam
Virgin Islands (british)
Virgin Islands (U.S.)
Wallis and Futuna Islands
Western Sahara
Yemen
Yugoslavia
Zambia
Zimbabwe
Code
KN
LC
VC
WS
SM
ST
SA
SN
SC
SL
SG
SK
SI
SB
SO
ZA
GS
ES
LK
SH
PM
SD
SR
SJ
SZ
SE
CH
SY
TW
TJ
TZ
TH
TG
TK
TO
TT
TN
TR
TM
TC
TV
UG
UA
AE
GB (UK)
US
UM
UY
UZ
VU
VE
VN
VG
VI
WF
EH
YE
YU
ZM
ZW
EXT: Language Selection based on domain - 7