Also ich habe es so gemacht, irgendwo mal gelesen und ausprobiert. Es funktioniert!
Dieses Beispiel geht davon aus, dass ich einen Seitenbaum (Single-Tree) verwende. Wenn die Übersetzung für eine Seite nicht vorliegt, wird die Default-Sprache (hier deutsch) angezeigt. Es wird oben im Bodybereich auf jeder Seite eine Zeile mit Flaggen eingebunden, die zum Sprachenwechsel angeklickt werden können. Angesehen werden kann das auf der Seite http://www.a-c-h.de. Dort ist auch zu sehen, was passiert wenn nicht alle Übersetzungen vorhanden sind.
Dafür müssen in Typo3 zuerst weitere Sprachen angelegt werden. Dies erreiche ich, indem ich im BE-Menü auf "Liste" gehe und im Seitenbaum die Rootseite anwähle. Dort kann über "Neuen Datensatz anlegen" eine (oder mehr) Sprache(n) hinzugefügt werden.
Natütlich müssen (sollten zum Testen) die Contents mit den verschiedenen Übersetzungen angelegt werden.
Dieser Teil kommt in den Bereich, in dem ich (ich benutze automaketemplate) die Marker von der html / css Templatevorlage anspreche.
..........
..........
page.20.marks {
# Hier kommen die Einstellungen für Marker Menues usw........
### Body #################################
# mehrere Seiteninhalte auf einer Seite --------------
BODY = COA
BODY.10 = PHP_SCRIPT
BODY.10.file = fileadmin/templates/scripts/languageMenu.php
BODY.20 < styles.content.get
BODY.20 {
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
}
# ende page.20.marks
}
Jetzt kommt der Konfigurationsteil, in dem ich die Sprachen festlege. Bei mir ist 0 default und deutsch. Dieser Teil steht entweder ganz am Anfang oder (wie bei mir) am Ende, ausserhalb des Bereiches, in dem ich die Marker anspreche.
config.doctype = xhtml_trans
config.xhtml_cleaning = all
config.htmlTag_langKey = de
# default Sprache Deutsch
config.linkVars = L
config.sys_language_uid = 0
config.metaCharset = iso-8859-1
config.locale_all = de_DE
config.language = de
# Sprache Niederlande
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.metaCharset = iso-8859-1
config.locale_all = nl_NL
config.language = nl
# Sprache Englisch
[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.metaCharset = iso-8859-1
config.locale_all = en_GB
config.language = en
#Sprache Dänisch
[globalVar = GP:L = 3]
config.sys_language_uid = 3
config.metaCharset = iso-8859-1
config.locale_all = dk_DK
config.language = dk
[global]
Das PHP-Script habe ich auch irgendwo gefunden, weiss nur nicht mehr wo, daher habe ich es hier komplett reingestellt.
Dieses PHP muß (so ist es bei mir) im
Verzeichnis: fileadmin/templates/scripts/languageMenu.php
liegen, dies ergibt sich aus der
Zeile: BODY.10.file = fileadmin/templates/scripts/languageMenu.php
im ersten Typoscript-Teil. Kann natürlich jeder anpassen.
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Creates a language-selector menu with three flags, an english, a danish and a german flag for each language supported on the site.
*
* THIS IS AN EXAMPLE designed to work with the official TYPO3 testsite, section "Another site in the ..."
* You will have to program a similar menu for your own case.
*
* $Id: example_languageMenu.php 1425 2006-04-12 19:42:41Z ingmars $
* Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
* XHTML compliant
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
*/
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=german, 1=niederlande and 2=english 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" align="middle" alt="" />';
// 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="typo3/sysext/cms/tslib/media/flags/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="typo3/sysext/cms/tslib/media/flags/flag_nl'.($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="typo3/sysext/cms/tslib/media/flags/flag_uk'.($langArr[2]?'':'_d').'.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==3?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=3').'" target="_top"><img src="typo3/sysext/cms/tslib/media/flags/flag_dk'.($langArr[3]?'':'_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><img src="clear.gif" width="30" height="1" alt="" /></td><td>'.implode('',$flags).'</td></tr></table>';
?>
Im PHP-Teil werden in den Zeilen 59 - 62 die Sprachen und die Flaggen festgelegt. Dort sind auch meine Anspassungen enthalten, die dies vom Original unterscheidet.
Achtung, in der Typo3 Ver. 3.x lagen die Flaggen in einem anderen Verzeichniss, was mich bei einem Update auf 4.x doch (wieder mal) etwas Schweiß gekostet hat.
Sollte sich ein Fehler eingeschlichen haben ist es eindeutig mein Fehler!