[open-ils-commits] SPAM: r8624 - in trunk/Open-ILS/xul/staff_client/chrome: content/main locale/en-US

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Feb 4 22:51:06 EST 2008


Author: dbs
Date: 2008-02-04 22:22:51 -0500 (Mon, 04 Feb 2008)
New Revision: 8624

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js
   trunk/Open-ILS/xul/staff_client/chrome/content/main/main.xul
   trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
Bring i18n to main.js


Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js	2008-02-05 02:00:47 UTC (rev 8623)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js	2008-02-05 03:22:51 UTC (rev 8624)
@@ -1,6 +1,8 @@
 dump('entering main/main.js\n');
 // vim:noet:sw=4:ts=4:
 
+var offlineStrings;
+
 function grant_perms(url) {
 	var perms = "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead";
 	dump('Granting ' + perms + ' to ' + url + '\n');
@@ -31,9 +33,12 @@
 	try {
 		clear_the_cache();
 
+		// Now we can safely load the strings without the cache getting wiped
+		offlineStrings = document.getElementById('offlineStrings');
+
 		if (typeof JSAN == 'undefined') {
 			throw(
-				"The JSAN library object is missing."
+				offlineStrings.getString('common.jsan.missing')
 			);
 		}
 		/////////////////////////////////////////////////////////////////////////////
@@ -48,7 +53,7 @@
 
 		JSAN.use('util.error');
 		G.error = new util.error();
-		G.error.sdump('D_ERROR','Testing');
+		G.error.sdump('D_ERROR', offlineStrings.getString('main.testing'));
 
 		JSAN.use('util.window');
 		G.window = new util.window();
@@ -57,7 +62,7 @@
 		G.auth = new auth.controller( { 'window' : mw } );
 
 		JSAN.use('OpenILS.data');
-		G.data = new OpenILS.data()
+		G.data = new OpenILS.data();
 		G.data.on_error = G.auth.logoff;
 
 		JSAN.use('util.file');
@@ -76,7 +81,7 @@
 
 			G.data.server_unadorned = url; G.data.stash('server_unadorned'); G.data.stash_retrieve();
 
-			if (! url.match( '^http://' ) ) url = 'http://' + url;
+			if (! url.match( '^http://' ) ) { url = 'http://' + url; }
 
 			G.data.server = url; G.data.stash('server'); 
 			G.data.session = { 'key' : G.auth.session.key, 'auth' : G.auth.session.authtime }; G.data.stash('session');
@@ -87,8 +92,8 @@
 			var xulG = {
 				'auth' : G.auth,
 				'url' : url,
-				'window' : G.window,
-			}
+				'window' : G.window
+			};
 
 			if (G.data.ws_info && G.data.ws_info[G.auth.controller.view.server_prompt.value]) {
 				JSAN.use('util.widgets');
@@ -106,7 +111,7 @@
 				iframe.contentWindow.xulG = xulG;
 				deck.selectedIndex = deck.childNodes.length - 1;
 			}
-		}
+		};
 
 		G.auth.on_standalone = function() {
 			try {
@@ -114,23 +119,23 @@
 			} catch(E) {
 				alert(E);
 			}
-		}
+		};
 
 		G.auth.on_standalone_export = function() {
 			try {
 				JSAN.use('util.file'); var file = new util.file('pending_xacts');
 				if (file._file.exists()) {
                     var file2 = new util.file('');
-					var f = file2.pick_file( { 'mode' : 'save', 'title' : 'Save Transaction File As' } );
+					var f = file2.pick_file( { 'mode' : 'save', 'title' : offlineStrings.getString('main.transaction_export.title') } );
 					if (f) {
 						if (f.exists()) {
 							var r = G.error.yns_alert(
-								'Would you like to overwrite the existing file ' + f.leafName + '?',
-								'Transaction Export Warning',
-								'Yes',
-								'No',
+								offlineStrings.getFormattedString('main.transaction_export.prompt', [f.leafName]),
+								offlineStrings.getString('main.transaction_export.prompt.title'),
+								offlineStrings.getString('common.yes'),
+								offlineStrings.getString('common.no'),
 								null,
-								'Check here to confirm this message'
+								offlineStrings.getString('common.confirm')
 							);
 							if (r != 0) { file.close(); return; }
 						}
@@ -138,12 +143,12 @@
 						e_file.write_content( 'truncate', file.get_content() );
 						e_file.close();
 						var r = G.error.yns_alert(
-							'Your transactions have been successfully exported to file ' + f.leafName + '.\n\nWe strongly recommend that you now purge the transactions from this staff client.  Would you like for us to do this?',
-							'Transaction Export Successful',
-							'Yes',
-							'No',
+							offlineStrings.getFormattedString('main.transaction_export.success.prompt', [f.leafName]),
+							offlineStrings.getString('main.transaction_export.success.title'),
+							offlineStrings.getString('common.yes'),
+							offlineStrings.getString('common.no'),
 							null,
-							'Check here to confirm this message'
+							offlineStrings.getString('common.confirm')
 						);
 						if (r == 0) {
 							var count = 0;
@@ -152,43 +157,45 @@
 							while (t_file._file.exists()) {
 								filename = 'pending_xacts_' + new Date().getTime() + '.exported';
 								t_file = new util.file(filename);
-								if (count++>100) throw('Error purging transactions:  Taking too long to find a unique filename for archival.');
+								if (count++ > 100) {
+									throw(offlineStrings.getString('main.transaction_export.filename.error'));
+								}
 							}
 							file._file.moveTo(null,filename);
 						} else {
-							alert('Please note that you now have two sets of identical transactions.  Unless the set you just exported is soley for archival purposes, we run the risk of duplicate transactions being processed on the server.');
+							alert(offlineStrings.getString('main.transaction_export.duplicate.warning'));
 						}
 					} else {
-						alert('No filename chosen.  Or a bug where you tried to overwrite an existing file.');
+						alert(offlineStrings.getString('main.transaction_export.no_filename.error'));
 					}
 				} else {
-					alert('There are no outstanding transactions to export.');
+					alert(offlineStrings.getString('main.transaction_export.no_transactions.error'));
 				}
 				file.close();
 			} catch(E) {
 				alert(E);
 			}
-		}
+		};
 
 		G.auth.on_standalone_import = function() {
 			try {
 				JSAN.use('util.file'); var file = new util.file('pending_xacts');
 				if (file._file.exists()) {
-					alert('There are already outstanding transactions on this staff client.  Upload these first.');
+					alert(offlineStrings.getString('main.transaction_import.outstanding.error'));
 				} else {
                     var file2 = new util.file('');
-					var f = file2.pick_file( { 'mode' : 'open', 'title' : 'Import Transaction File'} );
+					var f = file2.pick_file( { 'mode' : 'open', 'title' : offlineStrings.getString('main.transaction_import.title')} );
 					if (f && f.exists()) {
 						var i_file = new util.file(''); i_file._file = f;
 						file.write_content( 'truncate', i_file.get_content() );
 						i_file.close();
 						var r = G.error.yns_alert(
-							'Your transactions have been successfully migrated to this staff client.\n\nWe recommend that you delete the external copy.  Would you like for us to delete ' + f.leafName + '?',
-							'Transaction Import Successful',
-							'Yes',
-							'No',
+							offlineStrings.getFormattedString('main.transaction_import.delete.prompt', [f.leafName]),
+							offlineStrings.getString('main.transaction_import.success'),
+							offlineStrings.getString('common.yes'),
+							offlineStrings.getString('common.no'),
 							null,
-							'Check here to confirm this message'
+							offlineStrings.getString('common.confirm')
 						);
 						if (r == 0) {
 							f.remove(false);
@@ -199,7 +206,7 @@
 			} catch(E) {
 				alert(E);
 			}
-		}
+		};
 
 		G.auth.on_debug = function(action) {
 			switch(action) {
@@ -208,13 +215,13 @@
 				break;
 				case 'clear_cache' :
 					clear_the_cache();
-					alert('cache cleared');
+					alert(offlineStrings.getString('main.on_debug.clear_cache'));
 				break;
 				default:
-					alert('debug the debug :D');
+					alert(offlineStrings.getString('main.on_debug.debug'));
 				break;
 			}
-		}
+		};
 
 		G.auth.init();
 		// XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
@@ -229,7 +236,7 @@
 		//var x = document.getElementById('version_label');
 		//x.setAttribute('value','Build ID: ' + version);
 		var x = document.getElementById('about_btn');
-		x.setAttribute('label','About this client...');
+		x.setAttribute('label', offlineStrings.getString('main.about_btn.label'));
 		x.addEventListener(
 			'command',
 			function() {
@@ -251,14 +258,13 @@
 			//	},
 			//	false
 			//);
-			if (window.confirm('This version of the staff client stores local settings in a different location than your previous installation.  Should we attempt to migrate these settings?')) {
+			if (window.confirm(offlineStrings.getString('main.settings.migrate'))) {
 				setTimeout( function() { handle_migration(); }, 0 );
 			}
 		}
 
 	} catch(E) {
-		var error = "!! This software has encountered an error.  Please tell your friendly " +
-			"system administrator or software developer the following:\n" + E + '\n';
+		var error = offlineStrings.getFormattedString('common.error', [E, '']);
 		try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
 		alert(error);
 	}
@@ -285,17 +291,14 @@
 
 function handle_migration() {
 	if ( found_ws_info_in_Uchrome() ) {
-		alert('WARNING: Unable to migrate legacy settings.  The settings and configuration files appear to exist in multiple locations.\n'
-			+ 'To resolve manually, please consider:\n\t' + found_ws_info_in_Uchrome() + '\n'
-			+ 'which is in the directory where we want to store settings for the current OS user, and:\n\t'
-			+ found_ws_info_in_Achrome() + '\nwhich is where we used to store such information.\n'
+		alert(offlineStrings.getFormattedString('main.settings.migrate.failed', [found_ws_info_in_Uchrome(), found_ws_info_in_Achrome()])
 		);
 	} else {
 		var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties );
 		var f_new = dirService.get( "UChrm", Components.interfaces.nsIFile );
 		var f_old = dirService.get( "AChrom", Components.interfaces.nsIFile );
 		f_old.append(myPackageDir); f_old.append("content"); f_old.append("conf"); 
-		if (window.confirm("Move the settings and configuration files from\n" + f_old.path + "\nto\n" + f_new.path + "?")) {
+		if (window.confirm(offlineStrings.getFormattedString("main.settings.migrate.confirm", [f_old.path, f_new.path]))) {
 			var files = f_old.directoryEntries;
 			while (files.hasMoreElements()) {
 				var file = files.getNext();
@@ -303,10 +306,10 @@
 				try {
 					file2.moveTo( f_new, '' );
 				} catch(E) {
-					alert('Error trying to move ' + file2.path + ' to directory ' + f_new.path + '\n');
+					alert(offlineStrings.getFormattedString('main.settings.migrate.error', [file2.path, f_new.path]) + '\n');
 				}
 			}
-			location.href = location.href;
+			location.href = location.href; // huh?
 		}
 	}
 }

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/main.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/main.xul	2008-02-05 02:00:47 UTC (rev 8623)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/main.xul	2008-02-05 03:22:51 UTC (rev 8624)
@@ -56,6 +56,7 @@
 	</script>
 
 	<messagecatalog id="authStrings" src="chrome://open_ils_staff_client/locale/auth.properties"/>
+	<messagecatalog id="offlineStrings" src="chrome://open_ils_staff_client/locale/offline.properties"/>
 
 	<commandset id="auth_cmds">
 		<command id="cmd_login" />

Modified: trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties	2008-02-05 02:00:47 UTC (rev 8623)
+++ trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties	2008-02-05 03:22:51 UTC (rev 8624)
@@ -11,6 +11,8 @@
 common.barcode.status.warning.blocked=Blocked
 common.barcode.status.warning.unknown=with an unknown code: %1$s
 common.date.invalid=Invalid Date
+common.no=No
+common.yes=Yes
 common.unimplemented=Not Yet Implemented
 cat.bib_record=Bib Record: %1$s
 cat.opac.delete_record.confirm=Are you sure you want to delete title record #%1$s from the catalog?
@@ -121,3 +123,24 @@
 menu.close_tab.update_tab_label=Tab %1$s
 menu.new_tab.tab=Tab %1$s
 menu.set_tab.error=pause for error
+main.testing=Testing
+main.transaction_export.title=Save Transaction File As
+main.transaction_export.prompt=Would you like to overwrite the existing file %1$s?
+main.transaction_export.prompt.title=Transaction Export Warning
+main.transaction_export.success.prompt=Your transactions have been successfully exported to file %1$s. We strongly recommend that you now purge the transactions from this staff client.  Would you like for us to do this?
+main.transaction_export.success.title=Transaction Export Successful
+main.transaction_export.filename.error=Error purging transactions:  Taking too long to find a unique filename for archival.
+main.transaction_export.duplicate.warning=Please note that you now have two sets of identical transactions.  Unless the set you just exported is solely for archival purposes, we run the risk of duplicate transactions being processed on the server.
+main.transaction_export.no_filename.error=Either you did not choose a filename, or you tried to overwrite an existing file.
+main.transaction_export.no_transactions.error=There are no outstanding transactions to export.
+main.transaction_import.outstanding.error=There are already outstanding transactions on this staff client.  Upload these first.
+main.transaction_import.title=Import Transaction File
+main.transaction_import.delete.prompt=Your transactions have been successfully migrated to this staff client.\n\nWe recommend that you delete the external copy.  Would you like for us to delete %1$s?
+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.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
+main.settings.migrate.confirm=Move the settings and configuration files from\n%1$s\nto\n%2$s?
+main.settings.migrate.error=Error trying to move %1$s to directory %2$s



More information about the open-ils-commits mailing list