Code: Select all
<a href="index.php?home-d&lang=de" class="ym-button ym-xsmall">DE</a><a href="home-f&lang=fr.html" class="ym-button ym-xsmall">FR</a><a href="home-e&lang=en.html" class="ym-button ym-xsmall">EN</a>
Code: Select all
<a href="index.php?home-d&lang=de" class="ym-button ym-xsmall">DE</a><a href="home-f&lang=fr.html" class="ym-button ym-xsmall">FR</a><a href="home-e&lang=en.html" class="ym-button ym-xsmall">EN</a>
Code: Select all
<html lang="de">
Code: Select all
<?php
// Define some general language specifics
/**
* language setting based on site tree
* $phpwcms['allowed_lang'] = array('en', 'de', 'fr', 'es');
* - DE
* - EN
* - FR
* - ES
* ...
*/
$phpwcms['id_lang'] = array(
// ID LANG
1 => 'en',
2 => 'de' //,
// 3 => 'fr' ...
);
$phpwcms['lang_id'] = array_flip($phpwcms['id_lang']);
// Redirect to default language entry based on browser
if(!isset($LEVEL_ID[1])) {
// try to link user to correct language
$phpwcms['DOCTYPE_LANG'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) : $phpwcms['default_lang'];
if(!isset($phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']])) {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'];
}
// Get current alias
$pagelink = empty($content['struct'][ $phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] ]['acat_alias']) ? 'id='.$phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] : $content['struct'][ $phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] ]['acat_alias'];
$pagelink = $phpwcms["rewrite_url"] ? $pagelink . PHPWCMS_REWRITE_EXT : 'index.php?' . $pagelink;
// Redirect
headerRedirect(PHPWCMS_URL . $pagelink, 301);
} elseif(isset($phpwcms['id_lang'][ $LEVEL_ID[1] ])) {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'] = $phpwcms['id_lang'][ $LEVEL_ID[1] ];
} else {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'];
}
?>
Code: Select all
$phpwcms['allowed_lang'] = array('de','fr','en');
$phpwcms['DOCTYPE_LANG'] = ' ';
$phpwcms['default_lang'] = 'de';
Code: Select all
$phpwcms['id_lang'] = array(
// ID LANG
1 => 'de',
2 => 'fr',
3 => 'en'
);
Code: Select all
<?php
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
// set allowed languages
// set $phpwcms['allowed_lang'] in conf.inc.php
// $phpwcms['allowed_lang'] = array('en', 'de', 'fr', 'es');
$language_default = 'de';
$language_current = $language_default;
$language_cookie_duration = 60*60*24*365; // 1 year
if(isset($_GET['lang'])) {
$language_current = strtolower( substr($_GET['lang'], 0, 2) );
$_SESSION['phpwcmsFrontendLanguage'] = $language_current;
setcookie('phpwcmsFrontendLanguage', $language_current, time()+$language_cookie_duration, '/' );
} elseif(isset($_SESSION['phpwcmsFrontendLanguage'])) {
$language_current = $_SESSION['phpwcmsFrontendLanguage'];
} elseif(isset($_COOKIE['phpwcmsFrontendLanguage'])) {
$language_current = $_COOKIE['phpwcmsFrontendLanguage'];
}
if(!in_array($language_current, $phpwcms['allowed_lang'])) {
$language_current = $language_default;
$_SESSION['phpwcmsFrontendLanguage'] = $language_current;
setcookie('phpwcmsFrontendLanguage', $language_current, time()+$language_cookie_duration, '/' );
}
// init language replacements
$language_regexp = array( 'search' => array(), 'replace' => array() );
// set all language replacements now
foreach($phpwcms['allowed_lang'] as $lang) {
$language_regexp['search'][$lang] = '/\['.$lang.'\](.*?)\[\/'.$lang.'\]/is';
$language_regexp['replace'][$lang] = $lang == $language_current ? '$1' : '';
}
$content['all'] = preg_replace($language_regexp['search'], $language_regexp['replace'], $content['all']);
$content["pagetitle"] = preg_replace($language_regexp['search'], $language_regexp['replace'], $content["pagetitle"]);
?>
Code: Select all
; Overwrites the backend settings
; shop_url =
; cart_url =