[Kimchi-devel] [PATCH v2][Wok] Bug fix #151: Wok settings page not working when locale not set
Ramon Medeiros
ramonn at linux.vnet.ibm.com
Thu Nov 10 18:49:35 UTC 2016
Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
v2:
Check if language is available seeing the length of the return
ui/js/src/wok.login.js | 24 +++++++++++++++---------
ui/pages/login.html.tmpl | 4 ++--
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/ui/js/src/wok.login.js b/ui/js/src/wok.login.js
index 0b09508..fa2a98a 100644
--- a/ui/js/src/wok.login.js
+++ b/ui/js/src/wok.login.js
@@ -19,18 +19,24 @@
*/
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());
+ if ($('#userLang option[value="'+selectedLanguage+'"]').length == 1) {
+ $('#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());
-
+ if ($('#userLocale option[value="'+selectedLocale+'"]').length == 1) {
+ $('#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() {
wok.lang.set($(this).val());
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