lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steff...@apache.org
Subject svn commit: r1440014 - in /lucene/dev/trunk/solr: CHANGES.txt webapp/web/js/scripts/app.js
Date Tue, 29 Jan 2013 17:34:11 GMT
Author: steffkes
Date: Tue Jan 29 17:34:10 2013
New Revision: 1440014

URL: http://svn.apache.org/viewvc?rev=1440014&view=rev
Log:
SOLR-4364: Admin UI - Locale based number formatting

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/webapp/web/js/scripts/app.js

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1440014&r1=1440013&r2=1440014&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Jan 29 17:34:10 2013
@@ -115,6 +115,8 @@ Optimizations
 * SOLR-4284: Admin UI - make core list scrollable separate from the rest of
   the UI (steffkes)
 
+* SOLR-4364: Admin UI - Locale based number formatting (steffkes)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/app.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/app.js?rev=1440014&r1=1440013&r2=1440014&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/app.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/app.js Tue Jan 29 17:34:10 2013
@@ -175,6 +175,12 @@ var solr_admin = function( app_config )
 
   this.core_regex_base = '^#\\/([\\w\\d-\\.]+)';
 
+  browser = {
+    locale : null,
+    language : null,
+    country : null
+  };
+
   show_global_error = function( error )
   {
     var main = $( '#main' );
@@ -294,6 +300,24 @@ var solr_admin = function( app_config )
 
   this.run = function()
   {
+    var navigator_language = navigator.userLanguage || navigator.language;
+    var language_match = navigator_language.match( /^(\w{2})([-_](\w{2}))?$/ );
+    if( language_match )
+    {
+      if( language_match[1] )
+      {
+        browser.language = language_match[1].toLowerCase();
+      }
+      if( language_match[3] )
+      {
+        browser.country = language_match[3].toUpperCase();
+      }
+      if( language_match[1] && language_match[3] )
+      {
+        browser.locale = browser.language + '_' + browser.country
+      }
+    }
+
     $.ajax
     (
       {
@@ -536,7 +560,23 @@ var solr_admin = function( app_config )
 
   this.format_number = function format_number( number )
   {
-    return ( number || 0 ).toString().replace( /\B(?=(\d{3})+(?!\d))/g, ' ' );
+    var sep = {
+      'de_CH' : '\'',
+      'de' : '.',
+      'en' : ',',
+      'es' : '.',
+      'it' : '.',
+      'ja' : ',',
+      'sv' : ' ',
+      'tr' : '.',
+      '_' : '' // fallback
+    };
+
+    return ( number || 0 ).toString().replace
+    (
+      /\B(?=(\d{3})+(?!\d))/g,
+      sep[ browser.locale ] || sep[ browser.language ] || sep['_']
+    );
   };
 
 };



Mime
View raw message