[fusion-commits] r2383 - in trunk: common/php lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri May 20 06:22:41 EDT 2011
Author: liuar
Date: 2011-05-20 03:22:41 -0700 (Fri, 20 May 2011)
New Revision: 2383
Added:
trunk/common/php/GetLocale.php
Modified:
trunk/lib/fusion.js
Log:
Submit on behalf of SparkLiu.
Fix ticket #449 Locale will always the OS locale instead of locale in IE option when using IE
Added: trunk/common/php/GetLocale.php
===================================================================
--- trunk/common/php/GetLocale.php (rev 0)
+++ trunk/common/php/GetLocale.php 2011-05-20 10:22:41 UTC (rev 2383)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * GetLocale
+ *
+ * $Id: GetLocale.php 1806 2011-05-17 16:10:53Z sparkliu $
+ *
+ * Copyright (c) 2007, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+/**
+ * Return the locale of browser
+ */
+echo substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
+?>
Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js 2011-05-13 17:52:34 UTC (rev 2382)
+++ trunk/lib/fusion.js 2011-05-20 10:22:41 UTC (rev 2383)
@@ -1363,6 +1363,13 @@
Fusion._singleFile = singleFile;
var host = Fusion._getScriptLocation();
Jx.aPixel = Fusion.aPixel;
+
+ var getXmlHttpRequest = function(){
+ try { return new XMLHttpRequest(); }
+ catch (e) { try { return new ActiveXObject('Msxml2.XMLHTTP'); }
+ catch (e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); }
+ catch (e) { return null; }}}
+ }
//determine the language to use and add resource bundles to be loaded to the core scripts
var locale = navigator.language ?
@@ -1375,6 +1382,18 @@
var idx2 = temp.indexOf('&');
locale = temp.substring(0,idx2<0?temp.length:idx2);
}
+ else if(navigator.userAgent.indexOf("MSIE")>0) {
+ //This is because IE will always returns OS language instead of browser language. So we need the server side's help.
+ var xhr = getXmlHttpRequest();
+ xhr.open("GET", Fusion.fusionURL+"common/php/GetLocale.php",false);
+ xhr.send(null);
+ if(xhr.status == 200) {
+ var returnLocale = xhr.responseText;
+ if(returnLocale.length >= 2) {
+ locale = returnLocale.substring(0, 2);
+ }
+ }
+ }
window._FusionLocale = locale;
if (!Fusion._singleFile) {
@@ -1478,13 +1497,6 @@
document.writeln('<script src="' + src + '"><\/script>');
}
- var getXmlHttpRequest = function(){
- try { return new XMLHttpRequest(); }
- catch (e) { try { return new ActiveXObject('Msxml2.XMLHTTP'); }
- catch (e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); }
- catch (e) { return null; }}}
- }
-
/**
* Function: createSessionId
*
More information about the fusion-commits
mailing list