From: dbs Date: Sat, 15 Nov 2008 02:10:20 +0000 (+0000) Subject: Merge r11169 from trunk: add a basic locale switcher to the staff client X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7cbc56fadd0585da4fcc917a294ca4e410e687a5;p=Evergreen.git Merge r11169 from trunk: add a basic locale switcher to the staff client phasefx++ git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@11203 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index b10d2be7c8..5d8e0217a0 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -176,8 +176,15 @@ - - + + + + + + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js index 784c878b22..c0c9df330d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js +++ b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js @@ -131,6 +131,10 @@ auth.controller.prototype = { ['render'], function(e) { return function() {} } ], + 'apply_locale_btn' : [ + ['render'], + function(e) { return function() {} } + ], 'progress_bar' : [ ['render'], function(e) { return function() {} } @@ -369,6 +373,7 @@ auth.controller.prototype = { this.controller.view.name_prompt.disabled = true; this.controller.view.password_prompt.disabled = true; this.controller.view.submit_button.disabled = true; + this.controller.view.apply_locale_btn.disabled = true; XML_HTTP_SERVER = this.controller.view.server_prompt.value; try { @@ -458,6 +463,7 @@ auth.controller.prototype = { this.controller.view.progress_bar.value = 0; this.controller.view.progress_bar.setAttribute('real','0.0'); this.controller.view.submit_button.disabled = false; + this.controller.view.apply_locale_btn.disabled = false; this.controller.view.password_prompt.disabled = false; this.controller.view.password_prompt.value = ''; this.controller.view.name_prompt.disabled = false; diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index aa3c635f2f..da357b7fbe 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -236,10 +236,7 @@ function main_init() { document.getElementById('debug_gb').hidden = false; } window.title = authStrings.getFormattedString('staff.auth.titlebar.label', version); - //var x = document.getElementById('version_label'); - //x.setAttribute('value','Build ID: ' + version); var x = document.getElementById('about_btn'); - x.setAttribute('label', offlineStrings.getString('main.about_btn.label')); x.addEventListener( 'command', function() { @@ -251,7 +248,6 @@ function main_init() { ); var y = document.getElementById('new_window_btn'); - y.setAttribute('label', offlineStrings.getString('main.new_window_btn.label')); y.addEventListener( 'command', function() { @@ -268,6 +264,50 @@ function main_init() { false ); + JSAN.use('util.mozilla'); + var z = document.getElementById('locale_menupopup'); + if (z) { + while (z.lastChild) z.removeChild(z.lastChild); + var locales = util.mozilla.chromeRegistry().getLocalesForPackage( String( location.href ).split(/\//)[2] ); + var current_locale = util.mozilla.prefs().getCharPref('general.useragent.locale'); + while (locales.hasMore()) { + var locale = locales.getNext(); + var parts = locale.split(/-/); + var label; + try { + label = locale + ' : ' + util.mozilla.languages().GetStringFromName(parts[0]); + if (parts.length > 1) { + try { + label += ' (' + util.mozilla.regions().GetStringFromName(parts[1].toLowerCase()) + ')'; + } catch(E) { + label += ' (' + parts[1] + ')'; + } + } + } catch(E) { + label = locale; + } + var mi = document.createElement('menuitem'); + mi.setAttribute('label',label); + mi.setAttribute('value',locale); + if (locale == current_locale) { + if (z.parentNode.tagName == 'menulist') { + mi.setAttribute('selected','true'); + z.parentNode.setAttribute('label',label); + z.parentNode.setAttribute('value',locale); + } + } + z.appendChild( mi ); + } + } + var xx = document.getElementById('apply_locale_btn'); + xx.addEventListener( + 'command', + function() { + util.mozilla.change_locale(z.parentNode.value); + }, + false + ); + var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.xul b/Open-ILS/xul/staff_client/chrome/content/main/main.xul index 4f20549fb1..9fa643eb18 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.xul @@ -84,11 +84,16 @@ -