[open-ils-commits] r11203 - in branches/rel_1_4/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/auth xul/staff_client/chrome/content/main xul/staff_client/chrome/content/util xul/staff_client/chrome/locale/en-US
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 14 21:10:21 EST 2008
Author: dbs
Date: 2008-11-14 21:10:20 -0500 (Fri, 14 Nov 2008)
New Revision: 11203
Added:
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/mozilla.js
Modified:
branches/rel_1_4/Open-ILS/web/opac/locale/en-US/lang.dtd
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.js
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.xul
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
Merge r11169 from trunk: add a basic locale switcher to the staff client
phasefx++
Modified: branches/rel_1_4/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- branches/rel_1_4/Open-ILS/web/opac/locale/en-US/lang.dtd 2008-11-14 21:57:35 UTC (rev 11202)
+++ branches/rel_1_4/Open-ILS/web/opac/locale/en-US/lang.dtd 2008-11-15 02:10:20 UTC (rev 11203)
@@ -176,8 +176,15 @@
<!ENTITY staff.auth.quit_prompt.key "x">
<!ENTITY staff.auth.submit_prompt "Submit">
<!ENTITY staff.auth.submit_prompt.key "S">
-<!ENTITY staff.auth.title "Evergreen Staff Client 3">
-<!ENTITY staff.auth.version "Evergreen 0.1.0 20051202">
+<!ENTITY staff.auth.title "Evergreen Staff Client">
+<!ENTITY staff.auth.about_btn.label "About this client...">
+<!ENTITY staff.auth.about_btn.accesskey "">
+<!ENTITY staff.auth.new_window_btn.label "Open New Window">
+<!ENTITY staff.auth.new_window_btn.accesskey "N">
+<!ENTITY staff.auth.locale.label "Locale:">
+<!ENTITY staff.auth.locale.accesskey "e">
+<!ENTITY staff.auth.apply_locale_btn.label "Apply Locale">
+<!ENTITY staff.auth.apply_locale_btn.accesskey "A">
<!ENTITY staff.bills_current_payment_label "Current Payment">
<!ENTITY staff.bills_information "Information">
<!ENTITY staff.bills_interface_label "Bills">
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/auth/controller.js 2008-11-14 21:57:35 UTC (rev 11202)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/auth/controller.js 2008-11-15 02:10:20 UTC (rev 11203)
@@ -131,6 +131,10 @@
['render'],
function(e) { return function() {} }
],
+ 'apply_locale_btn' : [
+ ['render'],
+ function(e) { return function() {} }
+ ],
'progress_bar' : [
['render'],
function(e) { return function() {} }
@@ -369,6 +373,7 @@
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 @@
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;
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.js 2008-11-14 21:57:35 UTC (rev 11202)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.js 2008-11-15 02:10:20 UTC (rev 11203)
@@ -236,10 +236,7 @@
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 @@
);
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 @@
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);
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.xul
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.xul 2008-11-14 21:57:35 UTC (rev 11202)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/main/main.xul 2008-11-15 02:10:20 UTC (rev 11203)
@@ -84,11 +84,16 @@
<groupbox id="main_groupbox" flex="1" style="overflow: auto;">
<caption id="main_caption" label="&staff.main.auth.caption;"/>
<hbox>
- <label id="version_label"/>
- <button id="about_btn"/>
+ <button id="about_btn" label="&staff.auth.about_btn.label;" accesskey="&staff.auth.about_btn.accesskey;" />
- <label id="new_window_label"/>
- <button id="new_window_btn"/>
+ <button id="new_window_btn" label="&staff.auth.new_window_btn.label;" accesskey="&staff.auth.new_window_btn.accesskey;" />
+
+ <label value="&staff.auth.locale.label;" accesskey="&staff.auth.locale.accesskey;" control="locale_menu"/>
+ <menulist id="locale_menu">
+ <menupopup id="locale_menupopup">
+ </menupopup>
+ </menulist>
+ <button id="apply_locale_btn" label="&staff.auth.apply_locale_btn.label;" accesskey="&staff.auth.apply_locale_btn.accesskey;" />
</hbox>
<label value=" "/>
Copied: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/mozilla.js (from rev 11169, trunk/Open-ILS/xul/staff_client/chrome/content/util/mozilla.js)
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/mozilla.js (rev 0)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/mozilla.js 2008-11-15 02:10:20 UTC (rev 11203)
@@ -0,0 +1,75 @@
+dump('entering util/mozilla.js\n');
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+if (typeof util == 'undefined') var util = {};
+util.mozilla = {};
+
+util.mozilla.EXPORT_OK = [
+ 'chromeRegistry', 'languages', 'regions', 'prefs'
+];
+util.mozilla.EXPORT_TAGS = { ':all' : util.mozilla.EXPORT_OK };
+
+util.mozilla.chromeRegistry = function() {
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return Cc['@mozilla.org/chrome/chrome-registry;1'].getService(Ci['nsIToolkitChromeRegistry']);
+
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
+}
+
+util.mozilla.languages = function() {
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var stringBundles = Cc['@mozilla.org/intl/stringbundle;1'].getService(Ci['nsIStringBundleService']);
+ return stringBundles.createBundle('chrome://global/locale/languageNames.properties');
+
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
+}
+
+util.mozilla.regions = function() {
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var stringBundles = Cc['@mozilla.org/intl/stringbundle;1'].getService(Ci['nsIStringBundleService']);
+ return stringBundles.createBundle('chrome://global/locale/regionNames.properties');
+
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
+}
+
+util.mozilla.prefs = function() {
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return Cc['@mozilla.org/preferences-service;1'].getService(Ci['nsIPrefBranch']);
+
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
+}
+
+util.mozilla.change_locale = function( locale ) {
+ try {
+ var current_locale = 'en-US';
+ try { current_locale = util.mozilla.prefs().getCharPref('general.useragent.locale'); } catch(E) { alert('util.locale.change, prefs() = ' + E); }
+ if (locale != current_locale) {
+ util.mozilla.prefs().setCharPref('general.useragent.locale',locale);
+ util.mozilla.chromeRegistry().reloadChrome();
+ }
+
+ } catch(E) {
+ alert('FIXME: util.mozilla.change_locale( "' + locale + ") = " + E);
+ }
+}
+
+
+dump('exiting util/mozilla.js\n');
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2008-11-14 21:57:35 UTC (rev 11202)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2008-11-15 02:10:20 UTC (rev 11203)
@@ -149,8 +149,6 @@
main.transaction_import.success=Transaction Import Successful
main.on_debug.clear_cache=cache cleared
main.on_debug.debug=debug the debug :D
-main.about_btn.label=About this client...
-main.new_window_btn.label=Open New Window
main.new_window_btn.login_first_warning=Please login first!
main.settings.migrate=This version of the staff client stores local settings in a different location than your previous installation. Should we attempt to migrate these settings?
main.settings.migrate.failed=WARNING: Unable to migrate legacy settings. The settings and configuration files appear to exist in multiple locations. \nTo resolve this problem manually, please consider:\n\t%1$s\nwhich is in the directory where we want to store settings for the current operating system account, and:\n\t%2$s\nwhich is where we used to store such information.\n
More information about the open-ils-commits
mailing list