Zum Inhalt springen

Zwei Flaggen für die selbe Sprache

Erstellt am 23. Juni 2006 · 6 Antworten · letzte Antwort am 5. Juli 2006

Tags: Frage

Stoffel ·

Ich habe festgestellt, dass die Amis nicht gerne auf eine Flagge der Engländer klicken und umgekehrt! ;-) Aus diesem Grund möchte ich die beiden Flaggen getrennt darstellen, aber auf die selbe Seitensprache verweisen.

Dummerweise wird das in dem Standard-Skript über ein Array gelöst, und ich weiß nicht wie man den Code entsprechend abändern kann.

Wer kann mir helfen??

Stoffel ·

Ich habe naiverweise angenommen, mit der Bezeichnung "Standard-Skript" weiß jeder, was ich meine 🙂 Ich rede vom Skript tt_news_languageMenu.php
Mein Problem ist, dass ich nicht für Englisch eine Webseite-Sprache anlegen möchte und eine extra Webseite-Sprache für US-Amerikanisch. Ich muss es also irgendwie schaffen, zwei Flaggen einzubauen, die auf die selbe sys_language_uid verweisen (hab ich das so halbwegsverständlich erklärt??)

Vielen Dank schon im Voraus für Eure Hilfe!

<?php
/**
 * Copyright notice
 *
 *          (c) 1999-2004 Kasper Skaarhoj (kasper@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.
 *
 *
 * $Id: tt_news_languageMenu.php,v 1.14 2005/05/15 19:18:18 rupertgermann Exp $
 *
 * @author Rupert Germann <rupi@gmx.li>
 */

/**
 * language menu that keeps the links vars from tt_news
 *
 * @param	[type]		$content: ...
 * @return	void
 * @access public
 */
function user_languageMenu($content) {
	// image files for deafultlanguage
	$defaultflag = array(
		'on' => '<img src="fileadmin/images/flag_de.jpg" width="17" height="11" hspace="5" border="0" alt="" />',
		'off' => '<img src="fileadmin/images/flag_de_d.jpg" width="17" height="11" hspace="5" border="0" alt="" />',
	) ;


	// image files for additional languages. the numbers are the uids of the system languages
	$flagimages = array(
		'1' => array(
			'on' => '<img src="fileadmin/images/flag_us.jpg" width="17" height="11" hspace="5" border="0" alt="" />',
			'off' => '<img src="fileadmin/images/flag_us.jpg" width="17" height="11" hspace="5" border="0" alt="" />'
			),
		'2' => array(
			'on' => '<img src="fileadmin/images/flag_es.jpg" width="17" height="11" hspace="5" border="0" alt="" />',
			'off' => '<img src="fileadmin/images/flag_es.jpg" width="17" height="11" hspace="5" border="0" alt="" />'
			)
		);
	// Pointer for the active language
	
	//$pointer = '<img src="fileadmin/images/content_client.gif" width="7" height="10" alt="" />';




	// 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'];
	}

	$queryString = explode('&', t3lib_div::implodeArrayForUrl('', $GLOBALS['_GET'])) ;
	if ($queryString) {
		while (list(, $val) = each($queryString)) {
			$tmp = explode('=', $val);
			$paramArray[$tmp[0]] = $val;
		}
		$excludeList = 'id,L,tx_ttnews[pointer]';
		while (list($key, $val) = each($paramArray)) {
			if (!$val || ($excludeList && t3lib_div::inList($excludeList, $key))) {
				unset($paramArray[$key]);
			}
		}
		$tmpParams = implode($paramArray, '&');

		$newsAddParams = $tmpParams?'&' . $tmpParams:'';
	}
	// unset the global linkVar "L" for the language menu because it's build new in this script
	$linkVarsBak = $GLOBALS['TSFE']->linkVars;
	$tmplinkVars = t3lib_div::trimExplode('&', $GLOBALS['TSFE']->linkVars) ;
	if ($tmplinkVars) {
		while (list($kl, $vl) = each($tmplinkVars)) {
			if (!$vl || preg_match('/L=[0-9]/', $vl)) {
				unset($tmplinkVars[$kl]);
			}
		}
		$GLOBALS['TSFE']->linkVars = implode('&', $tmplinkVars) ;
	}

	$tmpLang = $GLOBALS['TSFE']->sys_language_uid;

	$flags = array();
	// flag for the default language
	if ($GLOBALS['TSFE']->page['l18n_cfg']==1){ // = "Hide default Translation" is activated
		$flags[0] = $defaultflag['off'];
	} else {
		$flags[0] = ($tmpLang == 0?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($defaultflag['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=0':$newsAddParams)));
	}

	// flags for the additional language
	if (is_array($flagimages)) {
		foreach ($flagimages as $fk => $fv) {
			if ($langArr[$fk]) {
				$flags[$fk] = ($tmpLang == $fk?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($fv['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=' . $fk:$newsAddParams)));
			} else {
				$flags[$fk] = $fv['off'];
			}
		}
	}
	$content = '<div class="langmenu"><p>'
	 . implode('', $flags) . '</p></div>';
	// restore link vars
	$GLOBALS['TSFE']->linkVars = $linkVarsBak;
	return $content;
}

?>
jenses ·

Die einfachste Lösung für Dich wäre wohl folgende:

#
$flagimages = array(
#
                '1' => array(
#
                        'on' => '<img src="fileadmin/images/flag_us.jpg" width="17" height="11" hspace="5" border="0" alt="" /><img src="fileadmin/images/flag_uk.jpg" width="17" height="11" hspace="5" border="0" alt="" />',
#
                        'off' => '<img src="fileadmin/images/flag_us.jpg" width="17" height="11" hspace="5" border="0" alt="" /><img src="fileadmin/images/flag_uk.jpg" width="17" height="11" hspace="5" border="0" alt="" />'
#
                        ),

D.h. Du läßt einfach beide Flaggen nebeneinander ausgeben, gemeinsam auf die Sprache "englisch" verlinkt.
Man könnte sicherlich auch das Script eleganter umbauen [mit einer if()-Abfrage], aber ohne PHP-Kenntnisse ist da nix zu wollen.
Und warum kompliziert, wenns auch einfach geht. 😉

Stoffel ·

Hi Jenses, diese Idee hatte ich schon ;-) Wenn ich halt einen Pointer verwenden möchte, dann steht dieser immer vor der ersten der beiden Flaggen, auch wenn ich auf die zweite klicke. Es ist ja nicht so, dass ich keine PHP Kenntnisse habe, immerhin habe ich schon eine kleine eigene Extension programmiert. Es ist nur so, dass ich in diesem Skript nicht durchsteige mit den ganzen Variablen und so ($fk, $fv .........)

Kannst Du mir nicht nen Tipp geben? Sonst muss ich mich halt mit dieser einfachen Lösung zufrieden geben ;-)

Bitbull ·

Hallo Stoffel,

was wäre gegen folgende - und recht oft praktizierte - Lösung einzuwenden?
Bild: dataco.de/uk_us.gif

Damit umgehst Du auch das Problem, Rechtfertigungen für das Fehlen doch teils sehr unterschiedliche Idiome (amerikanisch - englisch) finden zu müssen, die in Deiner Lösung ja eben nicht auftauchen würden.

Schöne Grüße

Bitbull

Stoffel ·

Hallo,

so eine Lösung hatte ich schon: die englische und die amerikanische Flagge haben sich alle 2 Sekunden abgewechselt (animiertes Gif).

Ich möchte aber lieber zwei separate Flaggen darstellen, damit jeder auf "seine eigene" Flagge klicken kann ;-)

Trotzdem vielen Dank für den Tipp!