mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 17:44:42 +03:00
get rid of smart getlocale, folders for languages
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@706 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
23e6e1edb5
commit
fa7330b365
6
site/.htaccess
Normal file
6
site/.htaccess
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
RewriteEngine on
|
||||||
|
|
||||||
|
RewriteCond %{HTTP_HOST} ^(www\.)?mibew\.org [NC]
|
||||||
|
RewriteBase /
|
||||||
|
RewriteRule ^(ru|en|sp)/(.*) $2?intlocale=$1 [L]
|
||||||
|
RewriteRule ^(ru|en|sp)$ $1/ [R,L]
|
@ -16,7 +16,7 @@
|
|||||||
if($k == $current_locale) {
|
if($k == $current_locale) {
|
||||||
echo "<a href=\"#\" class=\"inactive\">".$v."</a>";
|
echo "<a href=\"#\" class=\"inactive\">".$v."</a>";
|
||||||
} else {
|
} else {
|
||||||
echo "<a href=\"?locale=$k\">".$v."</a>";
|
echo "<a href=\"".($k != "en" ? "/$k" : "")."/\">".$v."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li<?php echo $page == 'home' ? ' class="active"' : '' ?>><a href="/index.php"><?php echo getlocal("menu.home") ?></a></li>
|
<li<?php echo $page == 'home' ? ' class="active"' : '' ?>><a href="index.php"><?php echo getlocal("menu.home") ?></a></li>
|
||||||
<li<?php echo $page == 'demo' ? ' class="active"' : '' ?>><a href="/demo.php"><?php echo getlocal("menu.demo") ?></a></li>
|
<li<?php echo $page == 'demo' ? ' class="active"' : '' ?>><a href="demo.php"><?php echo getlocal("menu.demo") ?></a></li>
|
||||||
<li<?php echo $page == 'downl' ? ' class="active"' : '' ?>><a href="/download.php"><?php echo getlocal("menu.download") ?></a></li>
|
<li<?php echo $page == 'downl' ? ' class="active"' : '' ?>><a href="download.php"><?php echo getlocal("menu.download") ?></a></li>
|
||||||
<li><a href="http://support.openwebim.org"><?php echo getlocal("menu.ticket") ?></a></li>
|
<li><a href="http://support.openwebim.org"><?php echo getlocal("menu.ticket") ?></a></li>
|
||||||
<li><a href="/forums/"><?php echo getlocal("menu.support") ?></a></li>
|
<li><a href="/forums/"><?php echo getlocal("menu.support") ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -42,52 +42,13 @@ function verifyparam( $name, $regexp, $default = null ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_locale() {
|
|
||||||
global $available_locales, $default_locale;
|
|
||||||
|
|
||||||
if( isset($_COOKIE['webim_locale']) ) {
|
|
||||||
$requested_lang = $_COOKIE['webim_locale'];
|
|
||||||
if( in_array($requested_lang,$available_locales) )
|
|
||||||
return $requested_lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {
|
|
||||||
$requested_langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
||||||
foreach( $requested_langs as $requested_lang) {
|
|
||||||
if( strlen($requested_lang) > 2 )
|
|
||||||
$requested_lang = substr($requested_lang,0,2);
|
|
||||||
|
|
||||||
if( in_array($requested_lang,$available_locales) && $requested_lang != 'ru' /* do not detect RU */ )
|
|
||||||
return $requested_lang;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( in_array($default_locale,$available_locales) )
|
|
||||||
return $default_locale;
|
|
||||||
|
|
||||||
return 'en';
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_locale() {
|
function get_locale() {
|
||||||
global $available_locales, $siteroot;
|
global $available_locales, $siteroot;
|
||||||
|
|
||||||
$locale = verifyparam("locale", "/^[\w-]{2,5}$/", "");
|
$locale = verifyparam("intlocale", "/^[\w-]{2,5}$/", "");
|
||||||
|
|
||||||
if( $locale && in_array($locale,$available_locales) ) {
|
|
||||||
$_SESSION['locale'] = $locale;
|
|
||||||
setcookie('webim_locale', $locale, time()+60*60*24*1000, "$siteroot/");
|
|
||||||
} else if( isset($_SESSION['locale']) ){
|
|
||||||
$locale = $_SESSION['locale'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !$locale || !in_array($locale,$available_locales) )
|
if( !$locale || !in_array($locale,$available_locales) )
|
||||||
$locale = get_user_locale();
|
|
||||||
|
|
||||||
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : "";
|
|
||||||
if( $locale == 'ru' && preg_match( "/googlebot[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent) ) {
|
|
||||||
$locale = "en";
|
$locale = "en";
|
||||||
}
|
|
||||||
|
|
||||||
return $locale;
|
return $locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user