[Kimchi-devel] [PATCH][Wok] Bug fix #151: Wok settings page not working when locale not set

Ramon Medeiros ramonn at linux.vnet.ibm.com
Tue Nov 8 21:24:59 UTC 2016


Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 ui/js/src/wok.login.js   | 27 +++++++++++++++++++--------
 ui/pages/login.html.tmpl |  4 ++--
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/ui/js/src/wok.login.js b/ui/js/src/wok.login.js
index 0b09508..6545858 100644
--- a/ui/js/src/wok.login.js
+++ b/ui/js/src/wok.login.js
@@ -19,17 +19,28 @@
  */
 wok.login_main = function() {
     "use strict";
+
+    // verify if language is available
     var selectedLanguage = wok.lang.get();
-    $('#userLang').val(selectedLanguage);
-    $('#userLang option[value="'+selectedLanguage+'"]').attr("selected", "selected");
-    $('.filter-option:first').parent().attr('title',$('#userLang option[value="'+selectedLanguage+'"]').text());
-    $('.filter-option:first').text($('#userLang option[value="'+selectedLanguage+'"]').text());
+    for (var i = 0; i < $('#userLang')[0].length; i++ ){
+        if ($('#userLang')[0][i] == selectedLanguage) {
+            $('#userLang').val(selectedLanguage);
+            $('#userLang option[value="'+selectedLanguage+'"]').attr("selected", "selected");
+            $('.filter-option:first').parent().attr('title',$('#userLang option[value="'+selectedLanguage+'"]').text());
+            $('.filter-option:first').text($('#userLang option[value="'+selectedLanguage+'"]').text());
+        }
+    }
 
+    // verify if locale is available
     var selectedLocale = wok.lang.get_locale();
-    $('#userLocale').val(selectedLocale);
-    $('#userLocale option[value="'+selectedLocale+'"]').attr("selected", "selected");
-    $('.filter-option:last').parent().attr('title',$('#userLocale option[value="'+selectedLocale+'"]').text());
-    $('.filter-option:last').text($('#userLocale option[value="'+selectedLocale+'"]').text());
+    for (var i = 0; i < $('#userLocale')[0].length; i++ ){
+        if ($('#userLocale')[0][i] == selectedLocale) {
+            $('#userLocale').val(selectedLocale);
+            $('#userLocale option[value="'+selectedLocale+'"]').attr("selected", "selected");
+            $('.filter-option:last').parent().attr('title',$('#userLocale option[value="'+selectedLocale+'"]').text());
+            $('.filter-option:last').text($('#userLocale option[value="'+selectedLocale+'"]').text());
+        }
+    }
 
 
     $('#userLang').on('change', function() {
diff --git a/ui/pages/login.html.tmpl b/ui/pages/login.html.tmpl
index 431806c..d74b795 100644
--- a/ui/pages/login.html.tmpl
+++ b/ui/pages/login.html.tmpl
@@ -128,7 +128,7 @@
                     <div class="form-group">
                         <label for="userLang">$_("Language")</label>
                         <select id="userLang" class="selectpicker col-md-12 col-lg-12">
-                            <option value="en_US">English (US)</option>
+                            <option value="en_US" selected="selected">English (US)</option>
                             <option value="zh_CN">中文(简体)</option>
                             <option value="pt_BR">Português (Brasil)</option>
                             <option value="de_DE">Deutsch (Deutschland)</option>
@@ -202,7 +202,7 @@
                            <option value="en-ZA">$_("English (South Africa)")</option>
                            <option value="en-TZ">$_("English (Tanzania)")</option>
                            <option value="en-GB">$_("English (United Kingdom)")</option>
-                           <option value="en-US">$_("English (United States)")</option>
+                           <option value="en-US" selected="selected">$_("English (United States)")</option>
                            <option value="en-ZM">$_("English (Zambia)")</option>
                            <option value="et-EE">$_("Estonian (Estonia)")</option>
                            <option value="tl-PH">$_("Filipino (Philippines)")</option>
-- 
2.7.4




More information about the Kimchi-devel mailing list