Zum Inhalt springen

Sprachauswahl im Header (topMenu) mit drei Sprachen - Introduction Package

Erstellt am 25. Januar 2011 · 5 Antworten · letzte Antwort am 11. Februar 2011

Tags: Frage

ralfred ·

Im Introduction Package ist ein Beispiel mit einer Sprachausgabe. Oben im Header wird eine Sprachauswahl in English und Dansk dargestellt.

menu.language:

menu.language = HMENU
menu.language {
	special = language
	special.value = 0,1
	1 = TMENU
	1 {
		wrap = <ul>|</ul>
		
		# Remove the (old) default behaviour which adds onfocus="blurLink(this);" to all links
		noBlur = 1
		
		NO = 1
		NO {
			# Override the standard menu item value (which is the page title) with our own cObject
			stdWrap.cObject = TEXT
			
			# Use the TypoScript option split function to display different values for the first and second item
			stdWrap.cObject.value = {$contentpage.language1} || {$contentpage.language2}
			allWrap = <li>|</li>
		}
		
		ACT < .NO
		ACT {
			ATagParams = class="active"
		}
	}
}

Ich hatte vergeblich eine dritte Sprache hinzufügen wollen. Für die Variable "$contentpage.language3" hatte ich eine dritte Sprache im Konstanteneditor >> Contentpage definiert und das "menu.language" erweitert:

stdWrap.cObject.value = {$contentpage.language1} || {$contentpage.language2} || {$contentpage.language3}

Hat leider nicht funktioniert. So habe ich zur Not die Extension "sr_language_menu" zur Sprachauswahl in Pluginform und "rlmp_language_detection" zur Spracherkennung installiert. Das läuft so weit ganz gut.

page.config:

# config.sys_language_overlay = 1

# Standardsprache festlegen
config.linkVars = L
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE.UTF-8

# english
[globalVar = GP:L=4]
config.sys_language_uid = 4
config.language = en
config.locale_all = en_EN.UTF-8
config.htmlTag_langKey = en
[global]

# spanish
[globalVar = GP:L=5]
config.sys_language_uid = 5
config.language = es
config.locale_all = es_ES.UTF-8
config.htmlTag_langKey = es
[global]

Habe auf jeder Seite das Plugin mit der Sprachauswahl eingefügt. Aber ich würde viel lieber die Flaggen oben im Header im "topMenu" ausgeben. Sieht optisch besser aus, nimmt keinen Platz im Contentbereich weg und muss nicht für jede neue Seite erneut eingebunden werde.
Wie bekomme ich die Flaggen dort oben hin?

ralfred ·

@king arthur - Vielen dank für den Hinweis >> special.value = 0,1

Um meine aktuelle Website nicht durcheinanderzubringen, möchte ich das Problem mit den Sprachlinks in einer frisch angelegten Testinstallation lösen. Als Grundlage verwende ich Typo3 4.5 LTS mit dem neuen Introduction Package. Zudem habe ich im BE eine Seite in drei Sprachübersetzungen (English, Deutsch, Español), angelegt. Ganz oben im Header werden alle drei Sprachen als Textlink dargestellt. Englisch und Deutsch funktionieren. Nur beim Klick auf den Spanisch-Link wird die Default-Sprache "Englisch" aufgerufen. Im Gegensatz zu Spanisch ist im deutschen Sprachlink eine "1" im Link enthalten. Im spanischen sollte eine "2" enthalten sein? Beim Klick auf den Spanisch-Link wird sogar der in Spanisch übersetzte Seitennamen aufgerufen. Nur der spanische Content fehlt.

http://localhost:8888/mywebsite/examples/language-n-english/
http://localhost:8888/mywebsite/1/examples/sprache-in-deutsch/
http://localhost:8888/mywebsite/examples/idioma-en-espanol/

Englisch bleibt "Default", Dansk ist in Deutsch geändert und als weitere Fremdsprache ist Spanisch hinzugefügt.
uid 0 = English
uid 1 = Deutsch
uid 2 = Español

Das Root Template ist auf Deutsch und Spanisch angepasst.

config {
	# cat=config; type=boolean; label=Admin Panel: Turn on admin panel (mainly for testing purposes only)
	adminPanel = 0

	# cat=config; type=boolean; label=Debugging: Turn on debugging (testing purposes only)
	debug = 0
	
	# cat=config; type=string; label=Domain name for Base URL: (excluding slashes and protocol like http://)
	domain = localhost:8888/bodtecd
}

filepaths {
	# cat=filepaths; type=string; label=HTML Templates: Location of the (X)HTML templates relative to site
	templates = fileadmin/default/templates/
	
	# cat=filepaths; type=string; label=CSS: Location of the Cascading Style Sheets relative to site
	css = fileadmin/default/templates/css/
	
	# cat=filepaths; type=string; label=Images: Location of the images relative to site
	images = fileadmin/default/templates/images/

	# cat=filepaths; type=string; label=Scripts: Location of the Javascript files relative to site
	scripts = fileadmin/default/templates/scripts/

	# cat=filepaths; type=string; label=HTML Templates for extensions: Location of the (X)HTML templates for extensions
	extensiontemplates = fileadmin/default/templates/extensions/
}

menu {
	# cat=navigation menus; type=string; label= Top-menu pages: Comma separated list of page id's to be included in top-right menu.
	top.pages = 28
}

plugin.tx_automaketemplate_pi1 {
	# cat=plugin.automaketemplate; type:string; label= HTML template file: Name of the HTML page template file (without path, see contant for filepath.templates)
	templatefile = typo3-intro-template.html
}

plugin.tt_news {
	# cat=plugin.tt_news; type=string; label= pid_list: Comma separated list of folder id's containing which contain news records.
	pid_list = 18
	
	# cat=plugin.tt_news; type=int+; label= singlePid: Default ID of the page containing the tt_news SINGLE-view plugin
	singlePid = 23
	
	# cat=plugin.tt_news; type=int+; label= limit: Default maximum number of items to be shown in LIST-view
	limit = 100
	
	# Date and time formats according to active locales
	dateformat = %x
	dateandtimeformat = %c
	
	# Short notation date format according to international ISO standard
	shortdateformat = %Y-%m-%d
	timeformat = %H:%M
}

plugin.tx_indexedsearch {
	# cat=plugin.indexed_search; type=int+; label= Search Page ID: UID of the page which contains the indexed search plugin.
	searchpageID = 17
}

plugin.meta {
	# cat=plugin.meta; type=string; label= Description: Write a short abstract for your website.
	description = This TYPO3 Introduction Package helps you to get started with TYPO3. It provides a basic website setup with examples for the most used features. On top of that, this package contains many helpful comments and notes on how the system works
	
	# cat=plugin.meta; type=string; label= Keywords: Enter a comma separated list of keywords.
	keywords = TYPO3, introduction package, install, demo site, example setup, content management, enterprise

	# cat=plugin.meta; type=string; label= Robots: Use for instance these codes: Index all pages: "all".  Index no pages: "none". Only this page: "index,nofollow".  Only subpages: "noindex,follow"
	robots = all

	# cat=plugin.meta; type=string; label= Copyright info: Enter copyright information, eg. "Me Myself and I, 2001. All rights reserved."
	copyright = typo3.org GPL

	# cat=plugin.meta; type=string; label= Reply-to email
	email = 

	# cat=plugin.meta; type=string; label= Author: Enter name of author.
	author = T3UXW09 / typo3.org
	
	# cat=plugin.meta; type=int+; label= Revisit after: Number of days between search engine visits.
	revisit = 7


	# The meta tags below are not used on this website, if you want to use these, you can configure that in TypoScript template page.meta
	
	# cat=plugin.meta; type=boolean; label=Always include global.
	includeGlobal = 

	# cat=plugin.meta; type=options[,Arabic=ar,Chinese=zh,Danish=dk,Dutch=nl,English=en,Finnish=fi,French=fr,German=de,Greek=el,Hebrew=he,Icelandic=is,Italian=it,Japanese=ja,Norwegian=no,Polish=pl,Portuguese=pt,Russian=ru,Spanish=es,Swedish=sv,Turkish=tr,Multi language=mul]; label= Language: Select language of the content.
	language = en
	
	# cat=plugin.meta; type=string; label= Distribution
	distribution = GLOBAL
	
	# cat=plugin.meta; type=options[,General,Mature,14 years,Restricted]; label= Rating
	rating = General	
}

styles.content {
	# This defines the maximum width of images inserted in content records of type Images or Text-with-images.
	# There are seperate settings for images floated next to text (..InText)
	imgtext {
		maxW = 651
		maxWInText = 651
		borderThick = 1
		linkWrap.newWindow = 1
	}
	uploads {
		jumpurl_secure = 1
		jumpurl_secure_mimeTypes = pdf=application/pdf, doc=application/msword
		jumpurl = 1
	}
}

contentpage {
	# cat=contentpage; type=int+; label= Footer source PID: Parent ID of the footer record used on content pages.
	footerPID = 20
	
	# cat=contentpage; type=int+; label= ID of the home page: ID of the home (root) page of the site.
	homeID = 1

	# cat=contentpage; type=int+; label= loginboxPID: ID of the folder containing the login box record (to be shown on multiple pages)
	loginboxPID = 21

	# cat=contentpage; type=int+; label= loginboxUID: UID of the login box record (to be shown on multiple pages)
	loginboxUID = 31

	# cat=contentpage; type=int+; label= loginpageID: UID of the customer login page.
	loginpageID = 28
	
	# cat=contentpage; type=int+; label= examplelanguagesID: UID of the page which has the language menu enabled
	examplelanguagesID = 25
	
	# cat=contentpage; type=string; label= language1: name of the default language of this site
	language1 = English

	# cat=contentpage; type=string; label= language2: name of the second language of this site
	language2 = Deutsch
	
	# cat=contentpage; type=string; label= language3: name of the second language of this site
	language3 = Español
}

# Set the language of meta tag with DC.language to german, when in german
[globalVar = GP:L = 1]
plugin.meta.language = de
[global]

# Set the language of meta tag with DC.language to spanish, when in spanish
[globalVar = GP:L = 2]
plugin.meta.language = es
[global]

Liste >> menu_configuration >> menu.language:

menu.language = HMENU

# We use a condition to show the language menu only on the page with the id from constant contentpage.examplelanguagesID
#[globalVar = TSFE:id = {$contentpage.examplelanguagesID}]

menu.language {
	special = language
	special.value = 0,1,2
	1 = TMENU
	1 {
		wrap = <ul>|</ul>
		
		# Remove the (old) default behaviour which adds onfocus="blurLink(this);" to all links
		noBlur = 1
		
		NO = 1
		NO {
			# Override the standard menu item value (which is the page title) with our own cObject
			stdWrap.cObject = TEXT
			
			# Use the TypoScript option split function to display different values for the first and second item
			stdWrap.cObject.value = {$contentpage.language1} || {$contentpage.language2} || {$contentpage.language3}
			allWrap = <li>|</li>
		}
		
		ACT < .NO
		ACT {
			ATagParams = class="active"
		}
	}
}

[global]

Liste >> page_configuration >> page.config:

config {
	// Administrator settings
	admPanel		= {$config.adminPanel}
	debug			= {$config.debug}
	
	doctype			= xhtml_trans

	// Character sets
	renderCharset 		= utf-8
	metaCharset 		= utf-8

	// Cache settings
        cache_period		= 43200
	sendCacheHeaders	= 1
        
	// URL Settings
	tx_realurl_enable       = 1
	simulateStaticDocuments = 0

	// Language Settings
	uniqueLinkVars          = 1
	linkVars                = L(1)
        sys_language_uid 	= 0
	sys_language_overlay 	= 1
	sys_language_mode 	= content_fallback
	language         	= en
	locale_all       	= en_EN.UTF-8
	htmlTag_langKey  	= en
	
	// Link settings
	# # # # # # absRefPrefix            = /
	prefixLocalAnchors      = all
	
	// Remove targets from links
	intTarget =
	extTarget =

	// Indexed Search
	index_enable		= 1
	index_externals		= 1

	// Code cleaning
	disablePrefixComment	= 1
	
	// Move default CSS and JS to external file	
	removeDefaultJS      	= external
	inlineStyle2TempFile 	= 1

	// Protect mail addresses from spamming
	spamProtectEmailAddresses = -3
	spamProtectEmailAddresses_atSubst = @<span style="display:none;">remove-this.</span>

	// Comment in the <head> tag
	headerComment (
	This TYPO3 introduction package has been started at T3UXW09
        
        ===
	)
}

# Set baseURL setting for http or https
config.baseURL = http://{$config.domain}/
[globalString = IENV:TYPO3_SITE_URL=https://{$config.domain}/]
config.baseURL = https://{$config.domain}/
[global]

// Condition to switch the doctype and xml prologue
[browser = msie] && [version = <7]
config {
	doctypeSwitch = 1
}
[global]

// Condition to set language according to L POST/GET variable
[globalVar = GP:L = 1]
config {
	htmlTag_langKey = de
	sys_language_uid = 1
	language = de
	locale_all = de_DE.UTF-8
}
[global]

[globalVar = GP:L = 2]
config {
	htmlTag_langKey = es
	sys_language_uid = 2
	language = es
	locale_all = es_ES.UTF-8
}
[global]

Was habe ich nicht berücksichtigt? Irgendwas muss da noch fehlen?

king arthur ·

Hallo,

hier muss wohl noch die Realurl-Konfiguration angepasst werden.

Folgendes sollte irgendwo in der Konfiguration stehen:

'preVars' => 
    array (
      0 => 
      array (
        'GETvar' => 'L',
        'valueMap' => 
        array (
          1 => '1',
        ),
        'noMatch' => 'bypass',
      ),
    ),

hier einfach dieses array erweitern:

array (
          1 => '1',
          2 => '2',
        ),

alternativ:

array (
          'de' => '1',
          'es' => '2',
        ),

Gruß Arthur

leinz_web ·

Hallo @king arthur,

habe ähnliche Probleme. –> Wo editiere ich diese PHP-Variablen für die Realurl-Konfiguration im Introduction Package?
Mein 4-Sprachmenu schaltet zwar brav die url um, nicht aber Navigation und Seiteninhalt, das bleibt default. 🙁

king arthur ·

Meistens im typo3conf-Ordner in:
realurl_autoconf.php
oder:
localconf.php
oder du benutzt eine Extension, wie z.B. aeurltool

Hast du denn die Seiten übersetzt?
Ohne Übersetzung auch keine übersetzten Inhalte und Navi-Punkte ;-)