Hi,
Das folgende Typo3Script sorgt für die Mehrsprachigkeit durch anfügen einer Variablen an jeden Link. Die letzten vier Zeilen setzen einen Fallback, also was soll passieren wenn es für eine Seite oder einen Seiteninhalt keine Übersetzung für die gewählte sprache gibt.
## Einstellungen fuer die Sprachauswahl [Beginn]
page.config.linkVars = L
page.config.sys_language_uid = 0
page.config.metaCharset = iso-8859-1
page.config.locale_all = de_DE
page.config.language = de
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 0
[globalVar = GP:L = 1]
page.config.sys_language_uid = 1
page.config.metaCharset = iso-8859-1
page.config.locale_all = en_GB
page.config.language = en
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 1
[global]
[globalVar = GP:L = 2]
page.config.sys_language_uid = 2
page.config.metaCharset = iso-8859-5
page.config.language = ru
page.config.locale_all = fr_FR
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3
[global]
page.config.sys_language_overlay = 1
page.config.sys_language_mode = content_fallback
page.config.sys_language_fallBackOrder=2,1,0
## Einstellungen fuer die Sprachauswahl [End]
Standart (0) ist hierbei Deutsch, 1 ist Englisch und 2 ist Französisch.
Im Root Ordner deiner Webseite legst Du nun die Sprachen Deiner Webseite an. Also z.B. Englisch und Französisch. 0,1,2 sind die ID´s der Datensätzen welche die einzelnen Sprachen repräsentieren.
Einbindung der Sprachwahl:
Hier gibt es verschiedene Möglichkeiten. Über TypoScript oder über ein externes Script. Folgendes Beispiel zeigt die Einbingung anhand eines externen Script.
Als erstes der TypoScriptCode:
## Language [Begin]
# Konfiguration der Sprache
# Einbingung eines PHP Scripts
lib.sprache = PHP_SCRIPT
lib.sprache.file = fileadmin/templates/scripte/languageMenu.inc
## Language [End]
An dem Marker sprache wird das Ergebnis des Scriptes languageMenu.inc ausgegeben.
Und dann das externe Script
<?php
if (!is_object($this)) die ('Error: No parent object present.');
// First, select all pages_language_overlay records on the current page. Each represents a possibility for a language.
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages_language_overlay', 'pid='.intval($GLOBALS['TSFE']->id).$GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'), 'sys_language_uid');
$langArr = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$langArr[$row['sys_language_uid']] = $row['title'];
}
// Little red arrow, which is inserted to the left of the flag-icon if the TSFE->sys_language_uid equals the language uid (notice that 0=english, 1=danish and 2=german is SPECIFIC to this database, because these numbers refer to uid's of the table sys_language)
//$pointer = '<img src="'.t3lib_extMgm::siteRelPath('cms').'tslib/media/icons_misc/content_client.gif" width="7" height="10" alt="" />';
$pointer = '';
// Set each icon. If the language is the current, red arrow is printed to the left. If the language is NOT found (represented by a pages_language_overlay record on this page), the icon is dimmed.
$flags = array();
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==0?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=0').'" target="_top"><img src="fileadmin/templates/images/basis/flag_de.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==1?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=1').'" target="_top"><img src="fileadmin/templates/images/basis/flag_uk'.($langArr[1]?'':'_d').'.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==2?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=2').'" target="_top"><img src="fileadmin/templates/images/basis/flag_fr'.($langArr[2]?'':'_d').'.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
// Make the little menu. Notice, the menu does ONLY transfer the page-id and the "L" variable (which is also SPECIFIC for this website because "L" has been used in the extension template used to control the language setup)
$content = '<table border="0" cellpadding="0" cellspacing="0"><tr><td>'.implode('',$flags).'</td></tr></table>';
?>
Dieses Script generiert die Flaggen für Deutschland, England und Frankreich. Gegebenefalls muss Du entsprechende Flaggen hochladen.
So nun viel Spaß beim Ausprobieren. Wenn Fragen gibt, einfach hier stellen oder PN an mich.
Gruß
febo