Author: cfinck
Date: Tue Sep 30 05:15:39 2008
New Revision: 36598
URL:
http://svn.reactos.org/svn/reactos?rev=36598&view=rev
Log:
- Get rid of the new language detection code incompatible to everything else
- Outsource and simplify the "check_lang" function, so we finally have only one
version of it
This fixes the auto-selection of languages in RosCMS and some other language-related
issues people were experiencing
Added:
trunk/web/reactos.org/htdocs/roscms/inc/language_detection.php (with props)
Removed:
trunk/web/reactos.org/htdocs/roscms/logon/language_detection.php
Modified:
trunk/web/reactos.org/htdocs/index.php
trunk/web/reactos.org/htdocs/roscms/index.php
trunk/web/reactos.org/htdocs/roscms/lang.php
trunk/web/reactos.org/htdocs/roscms/logon/user_profil_edit.php
trunk/web/reactos.org/htdocs/roscms/logon/user_register.php
Modified:
trunk/web/reactos.org/htdocs/index.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/index.php?r…
==============================================================================
---
trunk/web/reactos.org/htdocs/index.php [iso-8859-1] (original)
+++
trunk/web/reactos.org/htdocs/index.php [iso-8859-1] Tue Sep 30 05:15:39 2008
@@ -20,54 +20,7 @@
$roscms_page_format = ".html";
// Language detection
- function check_lang($lang)
- {
- if (preg_match('/^([a-zA-Z]+)(-[a-zA-Z]+)?$/', $lang, $matches)) {
- $checked_lang = strtolower($matches[1]);
- switch($checked_lang) {
- case 'ar':
- case 'bg':
- case 'ca':
- case 'cz':
- case 'da':
- case 'de':
- case 'el':
- case 'en':
- case 'es':
- case 'fr':
- case 'he':
- case 'hu':
- case 'id':
- case 'it':
- case 'ja':
- case 'ko':
- case 'lt':
- case 'nl':
- case 'no':
- case 'pl':
- case 'pt':
- case 'ru':
- case 'sv':
- case 'uk':
- case 'zh':
- case 'ro':
- case 'tw':
- case 'sk':
- case 'vi':
- break;
- default:
- $checked_lang = '';
- }
- }
- else if ($lang == '*') {
- $checked_lang = 'en';
- }
- else {
- $checked_lang = '';
- }
-
- return $checked_lang;
- }
+ require_once("roscms/inc/language_detection.php");
if (array_key_exists("page", $_GET))
$rpm_page=htmlspecialchars($_GET["page"]);
$rpm_lang = check_lang($_REQUEST['lang']);
Added:
trunk/web/reactos.org/htdocs/roscms/inc/language_detection.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/inc/…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/inc/language_detection.php (added)
+++
trunk/web/reactos.org/htdocs/roscms/inc/language_detection.php [iso-8859-1] Tue Sep 30
05:15:39 2008
@@ -1,0 +1,45 @@
+<?php
+ function check_lang($lang)
+ {
+ $lang = substr($lang, 0, 2);
+
+ switch($lang)
+ {
+ case 'ar':
+ case 'bg':
+ case 'ca':
+ case 'cz':
+ case 'da':
+ case 'de':
+ case 'el':
+ case 'en':
+ case 'es':
+ case 'fr':
+ case 'he':
+ case 'hu':
+ case 'id':
+ case 'it':
+ case 'ja':
+ case 'ko':
+ case 'lt':
+ case 'nl':
+ case 'no':
+ case 'pl':
+ case 'pt':
+ case 'ru':
+ case 'sv':
+ case 'uk':
+ case 'zh':
+ case 'ro':
+ case 'tw':
+ case 'sk':
+ case 'vi':
+ return $lang;
+ }
+
+ if($lang == "*")
+ return "en";
+
+ return "";
+ }
+?>
Propchange:
trunk/web/reactos.org/htdocs/roscms/inc/language_detection.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
trunk/web/reactos.org/htdocs/roscms/index.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/inde…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/index.php [iso-8859-1] (original)
+++
trunk/web/reactos.org/htdocs/roscms/index.php [iso-8859-1] Tue Sep 30 05:15:39 2008
@@ -123,6 +123,7 @@
//$rpm_lang = "en";
//require("inc/lang/en.php"); // preload the english language text
+ require_once("inc/language_detection.php");
require("lang.php"); // lang code outsourced
require("custom.php"); // custom on-screen information
@@ -204,7 +205,6 @@
break;
case "edit":
case "activate":
- include("logon/language_detection.php");
require("logon/user_profil_edit.php");
break;
}
@@ -223,7 +223,6 @@
require("inc/header.php");
create_header("", "logon");
require("logon/user_profil_menubar.php");
- include("logon/language_detection.php");
require("logon/user_profil_public.php");
require("inc/footer_closetable.php");
require("inc/footer.php");
@@ -253,7 +252,6 @@
}
else {
require("inc/header.php");
- include("logon/language_detection.php");
require("logon/user_register.php");
require("inc/footer.php");
}
Modified:
trunk/web/reactos.org/htdocs/roscms/lang.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/lang…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/lang.php [iso-8859-1] (original)
+++
trunk/web/reactos.org/htdocs/roscms/lang.php [iso-8859-1] Tue Sep 30 05:15:39 2008
@@ -1,55 +1,6 @@
<?php
// Language detection
-function check_lang($lang)
-{
- if (preg_match('/^([a-zA-Z]+)(-[a-zA-Z]+)?$/', $lang, $matches)) {
- $checked_lang = strtolower($matches[1]);
- switch($checked_lang) {
- case 'ar':
- case 'bg':
- case 'ca':
- case 'cz':
- case 'da':
- case 'de':
- case 'el':
- case 'en':
- case 'es':
- case 'fr':
- case 'he':
- case 'hu':
- case 'id':
- case 'it':
- case 'ja':
- case 'ko':
- case 'lt':
- case 'nl':
- case 'no':
- case 'pl':
- case 'pt':
- case 'ru':
- case 'sv':
- case 'uk':
- case 'zh':
- case 'ro':
- case 'tw':
- case 'sk':
- case 'vi':
- break;
- default:
- $checked_lang = '';
- }
- }
- else if ($lang == '*') {
- $checked_lang = 'en';
- }
- else {
- $checked_lang = '';
- }
-
- return $checked_lang;
-}
-
if ($rpm_lang == '' && isset($_COOKIE['roscms_usrset_lang'])) {
$rpm_lang = $_COOKIE['roscms_usrset_lang'];
if (substr($rpm_lang, -1) == '/') {
Removed:
trunk/web/reactos.org/htdocs/roscms/logon/language_detection.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/logo…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/logon/language_detection.php [iso-8859-1]
(original)
+++
trunk/web/reactos.org/htdocs/roscms/logon/language_detection.php (removed)
@@ -1,229 +1,0 @@
-<?php
-/*
- Script Name: Full Operating system language detection
- Author: Harald Hope, Website:
http://techpatterns.com/
- Script Source URI:
http://techpatterns.com/downloads/php_language_detection.php
- Version 0.3.4
- Copyright (C) 29 November 2007
- GNU GPL
-*/
-
-//$tmp = get_languages();
-//echo "<p>LANG: ".$tmp[0][0]."</p>";
-
-
-// choice of redirection header or just getting language data
-// to call this you only need to use the $feature parameter
-function get_languages()
-{
- // get the languages
- $a_languages = languages();
- $index = '';
- $complete = '';
- $found = false;// set to default value
- //prepare user language array
- $user_languages = array();
-
- //check to see if language is set
- if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) )
- {
- //explode languages into array
- $languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] );
- $languages = explode( ",", $languages );
-
- foreach ( $languages as $language_list )
- {
- // pull out the language, place languages into array of full and primary
- // string structure:
- $temp_array = array();
- // slice out the part before ; on first step, the part before - on second, place into
array
- $temp_array[0] = substr( $language_list, 0, strcspn( $language_list, ';' )
);//full language
- $temp_array[1] = substr( $language_list, 0, 2 );// cut out primary language
- //place this array into main $user_languages language array
- $user_languages[] = $temp_array;
- }
-
- //start going through each one
- for ( $i = 0; $i < count( $user_languages ); $i++ )
- {
- foreach ( $a_languages as $index => $complete )
- {
- if ( $index == $user_languages[$i][0] )
- {
- // complete language, like english (canada)
- $user_languages[$i][2] = $complete;
- // extract working language, like english
- $user_languages[$i][3] = substr( $complete, 0, strcspn( $complete, ' (' )
);
- }
- }
- }
- }
- else // if no languages found
- {
- $user_languages[0] = array( '','','','' ); //return
blank array.
- }
-
- return $user_languages;
-}
-
-function languages()
-{
-// pack abbreviation/language array
-// important note: you must have the default language as the last item in each major
language, after all the
-// en-ca type entries, so en would be last in that case
- $a_languages = array(
- 'af' => 'Afrikaans',
- 'sq' => 'Albanian',
- 'ar-dz' => 'Arabic (Algeria)',
- 'ar-bh' => 'Arabic (Bahrain)',
- 'ar-eg' => 'Arabic (Egypt)',
- 'ar-iq' => 'Arabic (Iraq)',
- 'ar-jo' => 'Arabic (Jordan)',
- 'ar-kw' => 'Arabic (Kuwait)',
- 'ar-lb' => 'Arabic (Lebanon)',
- 'ar-ly' => 'Arabic (libya)',
- 'ar-ma' => 'Arabic (Morocco)',
- 'ar-om' => 'Arabic (Oman)',
- 'ar-qa' => 'Arabic (Qatar)',
- 'ar-sa' => 'Arabic (Saudi Arabia)',
- 'ar-sy' => 'Arabic (Syria)',
- 'ar-tn' => 'Arabic (Tunisia)',
- 'ar-ae' => 'Arabic (U.A.E.)',
- 'ar-ye' => 'Arabic (Yemen)',
- 'ar' => 'Arabic',
- 'hy' => 'Armenian',
- 'as' => 'Assamese',
- 'az' => 'Azeri',
- 'eu' => 'Basque',
- 'be' => 'Belarusian',
- 'bn' => 'Bengali',
- 'bg' => 'Bulgarian',
- 'ca' => 'Catalan',
- 'zh-cn' => 'Chinese (China)',
- 'zh-hk' => 'Chinese (Hong Kong SAR)',
- 'zh-mo' => 'Chinese (Macau SAR)',
- 'zh-sg' => 'Chinese (Singapore)',
- 'zh-tw' => 'Chinese (Taiwan)',
- 'zh' => 'Chinese',
- 'hr' => 'Croatian',
- 'cs' => 'Czech',
- 'da' => 'Danish',
- 'div' => 'Divehi',
- 'nl-be' => 'Dutch (Belgium)',
- 'nl' => 'Dutch (Netherlands)',
- 'en-au' => 'English (Australia)',
- 'en-bz' => 'English (Belize)',
- 'en-ca' => 'English (Canada)',
- 'en-ie' => 'English (Ireland)',
- 'en-jm' => 'English (Jamaica)',
- 'en-nz' => 'English (New Zealand)',
- 'en-ph' => 'English (Philippines)',
- 'en-za' => 'English (South Africa)',
- 'en-tt' => 'English (Trinidad)',
- 'en-gb' => 'English (United Kingdom)',
- 'en-us' => 'English (United States)',
- 'en-zw' => 'English (Zimbabwe)',
- 'en' => 'English',
- 'us' => 'English (United States)',
- 'et' => 'Estonian',
- 'fo' => 'Faeroese',
- 'fa' => 'Farsi',
- 'fi' => 'Finnish',
- 'fr-be' => 'French (Belgium)',
- 'fr-ca' => 'French (Canada)',
- 'fr-lu' => 'French (Luxembourg)',
- 'fr-mc' => 'French (Monaco)',
- 'fr-ch' => 'French (Switzerland)',
- 'fr' => 'French (France)',
- 'mk' => 'FYRO Macedonian',
- 'gd' => 'Gaelic',
- 'ka' => 'Georgian',
- 'de-at' => 'German (Austria)',
- 'de-li' => 'German (Liechtenstein)',
- 'de-lu' => 'German (Luxembourg)',
- 'de-ch' => 'German (Switzerland)',
- 'de' => 'German (Germany)',
- 'el' => 'Greek',
- 'gu' => 'Gujarati',
- 'he' => 'Hebrew',
- 'hi' => 'Hindi',
- 'hu' => 'Hungarian',
- 'is' => 'Icelandic',
- 'id' => 'Indonesian',
- 'it-ch' => 'Italian (Switzerland)',
- 'it' => 'Italian (Italy)',
- 'ja' => 'Japanese',
- 'kn' => 'Kannada',
- 'kk' => 'Kazakh',
- 'kok' => 'Konkani',
- 'ko' => 'Korean',
- 'kz' => 'Kyrgyz',
- 'lv' => 'Latvian',
- 'lt' => 'Lithuanian',
- 'ms' => 'Malay',
- 'ml' => 'Malayalam',
- 'mt' => 'Maltese',
- 'mr' => 'Marathi',
- 'mn' => 'Mongolian (Cyrillic)',
- 'ne' => 'Nepali (India)',
- 'nb-no' => 'Norwegian (Bokmal)',
- 'nn-no' => 'Norwegian (Nynorsk)',
- 'no' => 'Norwegian (Bokmal)',
- 'or' => 'Oriya',
- 'pl' => 'Polish',
- 'pt-br' => 'Portuguese (Brazil)',
- 'pt' => 'Portuguese (Portugal)',
- 'pa' => 'Punjabi',
- 'rm' => 'Rhaeto-Romanic',
- 'ro-md' => 'Romanian (Moldova)',
- 'ro' => 'Romanian',
- 'ru-md' => 'Russian (Moldova)',
- 'ru' => 'Russian',
- 'sa' => 'Sanskrit',
- 'sr' => 'Serbian',
- 'sk' => 'Slovak',
- 'ls' => 'Slovenian',
- 'sb' => 'Sorbian',
- 'es-ar' => 'Spanish (Argentina)',
- 'es-bo' => 'Spanish (Bolivia)',
- 'es-cl' => 'Spanish (Chile)',
- 'es-co' => 'Spanish (Colombia)',
- 'es-cr' => 'Spanish (Costa Rica)',
- 'es-do' => 'Spanish (Dominican Republic)',
- 'es-ec' => 'Spanish (Ecuador)',
- 'es-sv' => 'Spanish (El Salvador)',
- 'es-gt' => 'Spanish (Guatemala)',
- 'es-hn' => 'Spanish (Honduras)',
- 'es-mx' => 'Spanish (Mexico)',
- 'es-ni' => 'Spanish (Nicaragua)',
- 'es-pa' => 'Spanish (Panama)',
- 'es-py' => 'Spanish (Paraguay)',
- 'es-pe' => 'Spanish (Peru)',
- 'es-pr' => 'Spanish (Puerto Rico)',
- 'es-us' => 'Spanish (United States)',
- 'es-uy' => 'Spanish (Uruguay)',
- 'es-ve' => 'Spanish (Venezuela)',
- 'es' => 'Spanish (Traditional Sort)',
- 'sx' => 'Sutu',
- 'sw' => 'Swahili',
- 'sv-fi' => 'Swedish (Finland)',
- 'sv' => 'Swedish',
- 'syr' => 'Syriac',
- 'ta' => 'Tamil',
- 'tt' => 'Tatar',
- 'te' => 'Telugu',
- 'th' => 'Thai',
- 'ts' => 'Tsonga',
- 'tn' => 'Tswana',
- 'tr' => 'Turkish',
- 'uk' => 'Ukrainian',
- 'ur' => 'Urdu',
- 'uz' => 'Uzbek',
- 'vi' => 'Vietnamese',
- 'xh' => 'Xhosa',
- 'yi' => 'Yiddish',
- 'zu' => 'Zulu' );
-
- return $a_languages;
-}
-?>
Modified:
trunk/web/reactos.org/htdocs/roscms/logon/user_profil_edit.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/logo…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/logon/user_profil_edit.php [iso-8859-1]
(original)
+++
trunk/web/reactos.org/htdocs/roscms/logon/user_profil_edit.php [iso-8859-1] Tue Sep 30
05:15:39 2008
@@ -142,12 +142,10 @@
!$existemail)
{
// user language (browser settings)
- $userlang = get_languages();
- $userlang2 = "en";
- if (strlen($userlang[0][0]) > 0 || strlen($userlang[0][0]) <= 5) {
- $userlang2 = $userlang[0][0];
- }
-
+ $userlang = check_lang($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+
+ if(!$userlang)
+ $userlang = "en";
// email address activation code
$s = "";
@@ -193,7 +191,7 @@
user_fullname =
'".mysql_real_escape_string($_POST['userfullname'])."',
".$updatemail."
user_website =
'".mysql_real_escape_string($_POST['userwebsite'])."',
- user_language =
'".mysql_real_escape_string($userlang2)."',
+ user_language =
'".mysql_real_escape_string($userlang)."',
user_country =
'".mysql_real_escape_string($_POST['country'])."',
user_timezone =
'".mysql_real_escape_string($_POST['tzone'])."',
user_occupation =
'".mysql_real_escape_string($_POST['useroccupation'])."',
Modified:
trunk/web/reactos.org/htdocs/roscms/logon/user_register.php
URL:
http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/logo…
==============================================================================
---
trunk/web/reactos.org/htdocs/roscms/logon/user_register.php [iso-8859-1] (original)
+++
trunk/web/reactos.org/htdocs/roscms/logon/user_register.php [iso-8859-1] Tue Sep 30
05:15:39 2008
@@ -152,12 +152,10 @@
$safename == "true" && $safepwd == "true"
&& !$existname && !$existemail)
{
// user language (browser settings)
- $userlang = get_languages();
- $userlang2 = "en";
- if (strlen($userlang[0][0]) > 0 && strlen($userlang[0][0]) <= 5)
{
- $userlang2 = $userlang[0][0];
- }
-
+ $userlang = check_lang($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+
+ if(!$userlang)
+ $userlang = "en";
// account activation code
$s = "";
@@ -184,7 +182,7 @@
NOW( ) ,
'".mysql_real_escape_string($account_act_code)."',
'".mysql_real_escape_string($_POST['useremail'])."',
- '".mysql_real_escape_string($userlang2)."');";
+ '".mysql_real_escape_string($userlang)."');";
$insert_new_account = mysql_query($sql_new_account);