[open-ils-commits] r7629 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client xul/staff_client/chrome/content/admin xul/staff_client/chrome/content/cat

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Aug 7 11:39:44 EDT 2007


Author: miker
Date: 2007-08-07 11:36:56 -0400 (Tue, 07 Aug 2007)
New Revision: 7629

Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/Makefile
   trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js
   trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul
   trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_wizard.xul
   trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul
Log:
Patch from Dan Scott which starts the process of proper staff client internationalization:

As documented at
http://developer.mozilla.org/en/docs/XUL_Tutorial:Property_Files ,
string bundles are the normal method for holding translatable text
from Javascript files in XULRunner applications. The staff client
currently does not use string bundles; it currently uses a mix of
hardcoded strings, with reliance on some of the strings that are
converted from lang.dtd into the massive hash that is lang.js.

This patch hopes to start changing that, by introducing string bundles
for a few small parts of the staff client -- hopefully paving the way
for conversion of more of the client to stringbundles and i18n glory.

1) We create one .properties file per chrome/content/ subdirectory
that we're converting to string bundles, plus a common.properties file
for common strings like error messages. In this patch, I address the
chrome/content/admin/ and chrome/content/cat/ directories; therefore,
I add:
 * Open-ILS/xul/staff_client/chrome/locale/en-US/admin.properties
 * Open-ILS/xul/staff_client/chrome/locale/en-US/cat.properties
 * Open-ILS/xul/staff_client/chrome/locale/en-US/common.properties

2) Note that the files are being added to a directory that does not
currently exist in the Subversion repository. It doesn't make sense to
serve the properties files remotely from the web/locale/en-US/
directory, as their real home is the chrome. So that's where I've
stuck them. Accordingly, the xul/staff_client/Makefile has been
modified to no longer make this directory.

3) chrome/content/cat/opac.xul has been converted to a fully i18n-ized
file, by adding XML entities to web/opac/locale/en-US/lang.dtd and
converting hardcoded strings in the Javascript to stringbundle calls
that pull in the properties defined in cat.properties and
common.properties.

4) chrome/content/admin/survey* have also been given the entity &
stringbundle treatment.

I have tested the opac and survey screens in the client and nothing
seems to be going wrong, so I'm taking that as a good sign :)



Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2007-08-07 15:36:56 UTC (rev 7629)
@@ -123,6 +123,17 @@
 <!ENTITY staff.au_survey_responses_label "Survey Responses">
 <!ENTITY staff.au_usrgroup_label "Usrgroup">
 <!ENTITY staff.au_usrname_label "Usrname">
+<!ENTITY staff.admin.survey.available.label "Available to:">
+<!ENTITY staff.admin.survey.description.label "Description:">
+<!ENTITY staff.admin.survey.end.label "End:">
+<!ENTITY staff.admin.survey.format.label "Poll Format:">
+<!ENTITY staff.admin.survey.name.label "Name:">
+<!ENTITY staff.admin.survey.opac_visible.label "OPAC Visible:">
+<!ENTITY staff.admin.survey.required.label "Required:">
+<!ENTITY staff.admin.survey.save_question.accesskey "q">
+<!ENTITY staff.admin.survey.save_question.label "Save this Question">
+<!ENTITY staff.admin.survey.staff_client.label "Staff Client:">
+<!ENTITY staff.admin.survey.start.label "Start:">
 <!ENTITY staff.auth.login_header "Login">
 <!ENTITY staff.auth.logoff_prompt "Log Off">
 <!ENTITY staff.auth.logoff_prompt.accesskey "f">
@@ -185,6 +196,34 @@
 <!ENTITY staff.cat.fixed.SER.key "S">
 <!ENTITY staff.cat.fixed.VIS "VIS">
 <!ENTITY staff.cat.fixed.VIS.key "V">
+<!ENTITY staff.cat.opac.add_bucket.accesskey "B">
+<!ENTITY staff.cat.opac.add_bucket.label "Add to Bucket">
+<!ENTITY staff.cat.opac.bib_in_new_tab.label "Duplicate in New Tab">
+<!ENTITY staff.cat.opac.copy_browse.accesskey "H">
+<!ENTITY staff.cat.opac.copy_browse.label "Holdings Maintenance">
+<!ENTITY staff.cat.opac.default.label "Set bottom interface as Default">
+<!ENTITY staff.cat.opac.marc_edit.accesskey "E">
+<!ENTITY staff.cat.opac.marc_edit.label "MARC Edit">
+<!ENTITY staff.cat.opac.marc_view.accesskey "V">
+<!ENTITY staff.cat.opac.marc_view.label "MARC View">
+<!ENTITY staff.cat.opac.mark_for_overlay.accesskey "M">
+<!ENTITY staff.cat.opac.mark_for_overlay.label "Mark for Overlay">
+<!ENTITY staff.cat.opac.menu.accesskey "A">
+<!ENTITY staff.cat.opac.menu.label "Actions for this Record">
+<!ENTITY staff.cat.opac.opac_view.accesskey "O">
+<!ENTITY staff.cat.opac.opac_view.label "OPAC View">
+<!ENTITY staff.cat.opac.record_end.accesskey "E">
+<!ENTITY staff.cat.opac.record_end.label "End">
+<!ENTITY staff.cat.opac.record_next.accesskey "N">
+<!ENTITY staff.cat.opac.record_next.label "Next">
+<!ENTITY staff.cat.opac.record_prev.accesskey "P">
+<!ENTITY staff.cat.opac.record_prev.label "Previous">
+<!ENTITY staff.cat.opac.record_start.accesskey "S">
+<!ENTITY staff.cat.opac.record_start.label "Start">
+<!ENTITY staff.cat.opac.refresh_me.label "Reset Display">
+<!ENTITY staff.cat.opac.remove_me.label "Remove this Frame">
+<!ENTITY staff.cat.opac.view_holds.accesskey "s">
+<!ENTITY staff.cat.opac.view_holds.label "View Holds">
 <!ENTITY staff.cat.popup.add_to_bucket "Add to Bucket">
 <!ENTITY staff.cat.popup.add_to_bucket.key "">
 <!ENTITY staff.cat.popup.browse.record.tab.key "">

Modified: trunk/Open-ILS/xul/staff_client/Makefile
===================================================================
--- trunk/Open-ILS/xul/staff_client/Makefile	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/xul/staff_client/Makefile	2007-08-07 15:36:56 UTC (rev 7629)
@@ -35,10 +35,6 @@
 
 build_dir:
 	@echo
-	@echo '*********************************************************  Kludge, make sure these directories exists '
-	mkdir -p chrome/locale/en-US/
-	#mkdir -p chrome/content/OpenSRF/
-	@echo
 	@echo '*********************************************************  Creating and populating build/ '
 	mkdir -p build/
 	cp -R chrome build/

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey.js	2007-08-07 15:36:56 UTC (rev 7629)
@@ -247,8 +247,9 @@
 	g_row_2.appendChild(g_tb);
 	if (last_button) last_button.setAttribute('accesskey','');
 	var g_b = document.createElement('button');
-		g_b.setAttribute('label','Save this Response');
-		g_b.setAttribute('accesskey','R');
+	var strbundle = document.getElementById("adminStrings");
+		g_b.setAttribute('label', strbundle.getString('staff.admin.survey.save_response.label'));
+		g_b.setAttribute('accesskey', strbundle.getString('staff.admin.survey.save_response.label'));
 		g_b.setAttribute('oncommand','add_answer(event,' + my_asvq.id() + ');');
 	g_row_2.appendChild(g_b);
 

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul	2007-08-07 15:36:56 UTC (rev 7629)
@@ -20,48 +20,48 @@
 		</columns>
 		<rows id="page1_grid1_rows">
 			<row id="page1_grid1_row1">
-				<label id="page1_row1_label1" value="Available to:" class="wizard_label"/>
+				<label id="page1_row1_label1" value="&staff.admin.survey.available.label;" class="wizard_label"/>
 				<menulist id="lib_menulist">
 					<menupopup id="lib_menupopup"/>
 				</menulist>
 			</row>
 
 			<row id="page1_grid1_row2">
-				<label id="page1_row2_label1" value="Name:" class="wizard_label"/>
+				<label id="page1_row2_label1" value="&staff.admin.survey.name.label;" class="wizard_label"/>
 				<textbox id="survey_name" onchange="page1_check_advance();" onkeyup="page1_check_advance();" />
 			</row>
 
 			<row id="page1_grid1_row3">
-				<label id="page1_row3_label1" value="Description:" class="wizard_label"/>
+				<label id="page1_row3_label1" value="&staff.admin.survey.description.label;" class="wizard_label"/>
 				<textbox id="survey_description" multiline="true" rows="4"/>
 			</row>
 
 			<row>
-				<label id="page1_row1_label2" value="Required:" class="wizard_label"/>
+				<label id="page1_row1_label2" value="&staff.admin.survey.required.label;" class="wizard_label"/>
 				<checkbox id="required_checkbox"/>
 			</row>
 			
 			<row id="page1_grid1_row1c">
-				<label id="page1_row1c_label3" value="Poll Format:" class="wizard_label"/>
+				<label id="page1_row1c_label3" value="&staff.admin.survey.format.label;" class="wizard_label"/>
 				<checkbox id="poll_checkbox"/>
 			</row>
 
 
 			<row id="page1_grid1_row1a">
-				<label id="page1_row1a_label3" value="OPAC Visible:" class="wizard_label"/>
+				<label id="page1_row1a_label3" value="&staff.admin.survey.opac_visible.label;" class="wizard_label"/>
 				<checkbox id="opac_checkbox"/>
 			</row>
 
 			<row id="page1_grid1_row1b">
-				<label id="page1_row1b_label3" value="Staff Client:" class="wizard_label"/>
+				<label id="page1_row1b_label3" value="&staff.admin.survey.staff_client.label;" class="wizard_label"/>
 				<checkbox id="patron_summary_checkbox"/>
 			</row>
 			<row id="page1_grid1_row1d">
-				<label id="page1_row2_label2" value="Start:" class="wizard_label"/>
+				<label id="page1_row2_label2" value="&staff.admin.survey.start.label;" class="wizard_label"/>
 				<textbox id="survey_start"/>
 			</row>
 			<row>
-				<label id="page1_row3_label2" value="End:" class="wizard_label"/>
+				<label id="page1_row3_label2" value="&staff.admin.survey.end.label;" class="wizard_label"/>
 				<textbox id="survey_end"/>
 			</row>
 		</rows>
@@ -89,7 +89,7 @@
 		<row id="page2_grid1_row1">
 			<label id="new_question_label" value="#1"/>
 			<textbox id="new_question" flex="1"/>
-			<button id="page2_button1" label="Save this Question" accesskey="q" oncommand="add_question(event);"/>
+			<button id="page2_button1" label="&staff.admin.survey.save_question.label;" accesskey="&staff.admin.survey.save_question.accesskey;" oncommand="add_question(event);"/>
 		</row>
 	</rows>
 

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_wizard.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_wizard.xul	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/admin/survey_wizard.xul	2007-08-07 15:36:56 UTC (rev 7629)
@@ -28,7 +28,7 @@
 		function my_init() {
 			try {
 				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-		                if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+		                if (typeof JSAN == 'undefined') { throw( document.getElementById("commonStrings").getString('common.jsan.missing'); }
 				JSAN.errorLevel = "die"; // none, warn, or die
 				JSAN.addRepository('..');
 				JSAN.use('util.error'); g.error = new util.error();
@@ -48,8 +48,7 @@
 				document.getElementById('survey_add').canAdvance = false; 
 	
 			} catch(E) {
-				var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
-					"system administrator or software developer the following:\nsurvey_wizard.xul\n" + E + '\n';
+				var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['survey_wizard.xul', E]);
 				try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
 				alert(err_msg);
 			}
@@ -57,6 +56,11 @@
 	]]>
 	</script>
 
+	<stringbundleset id="adminSet">
+		<stringbundle id="commonStrings" src="chrome://open_ils_staff_client/locale/common.properties"/>
+		<stringbundle id="adminStrings" src="chrome://open_ils_staff_client/locale/admin.properties"/>
+	</stringbundleset>
+
 	<!-- Layout to be filled in by overlays and javascript -->
 	<wizardpage id="page1"/>
 	<wizardpage id="page2"/>

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul	2007-08-07 15:31:22 UTC (rev 7628)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul	2007-08-07 15:36:56 UTC (rev 7629)
@@ -38,7 +38,7 @@
 		function my_init() {
 			try {
 				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                if (typeof JSAN == 'undefined') { throw(document.getElementById('commonStrings').getString('common.jsan.missing')); }
 				JSAN.errorLevel = "die"; // none, warn, or die
 				JSAN.addRepository('..');
 				JSAN.use('util.error'); g.error = new util.error();
@@ -61,8 +61,7 @@
 				set_opac();
 
 			} catch(E) {
-				var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
-					"system administrator or software developer the following:\ncat/opac.xul\n" + E + '\n';
+				var err_msg = document.getElementById("commonStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
 				try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
 				alert(err_msg);
 			}
@@ -77,7 +76,7 @@
 				{ 
 					'set_tab_name' : function(n) { 
 						if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
-							try { window.xulG.set_tab_name('Bib Record: ' + n); } catch(E) { alert(E); }
+							try { window.xulG.set_tab_name(document.getElementById('catStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
 						} else {
 							dump('no set_tab_name\n');
 						}
@@ -96,23 +95,24 @@
 		}
 
 		function set_marc_edit(reset) {
+			var strbundle = document.getElementById('catStrings');
 			g.view = 'marc_edit';
 			var a =	xulG.url_prefix( urls.XUL_MARC_EDIT );
 			var b =	{};
 			var c =	{
 					'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
 					'save' : {
-						'label' : 'Save Record',
+						'label' : strbundle.getString('cat.save_record'),
 						'func' : function (new_marcxml) {
 							try {
 								var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
 								if (typeof r.ilsevent != 'undefined') {
 									throw(r);
 								} else {
-									alert('Record successfully saved.');
+									alert(strbundle.getString("cat.save.success"));
 								}
 							} catch(E) {
-									g.error.standard_unexpected_error_alert('Record not likely updated.',E);
+									g.error.standard_unexpected_error_alert(strbundle.getString("cat.save.failure"), E);
 							}
 						}
 					}
@@ -191,7 +191,7 @@
 
 						win.attachEvt("rdetail", "nextPrevDrawn",
 							function(rIndex,rCount){
-								$('record_pos').setAttribute('value','Record ' + (1+rIndex) + ' of ' + rCount);
+								$('record_pos').setAttribute('value', document.getElementById('catStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount]));
 								if (win.rdetailNext) {
 									g.f_record_next = function() { 
 										g.view_override = g.view; 
@@ -302,39 +302,44 @@
 				[ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
 			)
 			if (typeof robj.ilsevent != 'undefined') {
-				if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert('Preference not likely updated.',robj);
+				if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('cat.preference.error'), robj);
 			}
 		}
 
 	]]>
 	</script>
 
+	<stringbundleset id="catBundleSet">
+		<stringbundle id="commonStrings" src="chrome://open_ils_staff_client/locale/common.properties"/>
+		<stringbundle id="catStrings" src="chrome://open_ils_staff_client/locale/cat.properties"/>
+	</stringbundleset>
+
 	<vbox flex="1">
 		<deck id="top_pane"/>
 		<hbox id="nav" hidden="true">
 			<label id="record_pos"/>
-			<button id="record_start" accesskey="S" label="Start" oncommand="if (g.f_record_start) g.f_record_start();"/>
-			<button id="record_prev" accesskey="P" label="Previous" oncommand="if (g.f_record_prev) g.f_record_prev();"/>
-			<button id="record_next" accesskey="N" label="Next" oncommand="if (g.f_record_next) g.f_record_next();"/>
-			<button id="record_end" accesskey="E" label="End" oncommand="if (g.f_record_end) g.f_record_end();"/>
+			<button id="record_start" accesskey="&staff.cat.opac.record_start.accesskey;" label="&staff.cat.opac.record_start.label;" oncommand="if (g.f_record_start) g.f_record_start();"/>
+			<button id="record_prev" accesskey="&staff.cat.opac.record_prev.accesskey;" label="&staff.cat.opac.record_prev.label;" oncommand="if (g.f_record_prev) g.f_record_prev();"/>
+			<button id="record_next" accesskey="&staff.cat.opac.record_next.accesskey;" label="&staff.cat.opac.record_next.label;" oncommand="if (g.f_record_next) g.f_record_next();"/>
+			<button id="record_end" accesskey="&staff.cat.opac.record_end.accesskey;" label="&staff.cat.opac.record_end.label;" oncommand="if (g.f_record_end) g.f_record_end();"/>
 			<spacer flex="1"/>
 			<menubar>
-				<menu label="Actions for this Record" accesskey="A">
+				<menu label="&staff.cat.opac.menu.label;" accesskey="&staff.cat.opac.menu.accesskey;">
 				<menupopup>
-				<menuitem label="OPAC View" accesskey="O" id="opac_view" oncommand="set_opac();"/>
-				<menuitem label="MARC View" accesskey="V" id="marc_view" oncommand="set_marc_view();"/>
-				<menuitem label="MARC Edit" accesskey="E" id="marc_edit" oncommand="set_marc_edit();"/>
-				<menuitem label="Holdings Maintenance" accesskey="H" id="copy_browse" oncommand="set_copy_browser();"/>
-				<menuitem label="View Holds" accesskey="s" id="view_holds" oncommand="set_hold_browser();"/>
+				<menuitem label="&staff.cat.opac.opac_view.label;" accesskey="" id="opac_view" oncommand="set_opac();"/>
+				<menuitem label="&staff.cat.opac.marc_view.label;" accesskey="&staff.cat.opac.marc_view.accesskey;" id="marc_view" oncommand="set_marc_view();"/>
+				<menuitem label="&staff.cat.opac.marc_edit.label;" accesskey="&staff.cat.opac.marc_edit.accesskey;" id="marc_edit" oncommand="set_marc_edit();"/>
+				<menuitem label="&staff.cat.opac.copy_browse.label;" accesskey="&staff.cat.opac.copy_browse.accesskey;" id="copy_browse" oncommand="set_copy_browser();"/>
+				<menuitem label="&staff.cat.opac.view_holds.label;" accesskey="&staff.cat.opac.view_holds.accesskey;" id="view_holds" oncommand="set_hold_browser();"/>
 				<menuseparator/>
-				<menuitem label="Add to Bucket" accesskey="B" id="add_bucket" oncommand="add_to_bucket();"/>
-				<menuitem label="Mark for Overlay" accesskey="M" id="mark_for_overlay" oncommand="mark_for_overlay();"/>
+				<menuitem label="&staff.cat.opac.add_bucket.label;" accesskey="&staff.cat.opac.add_bucket.accesskey;" id="add_bucket" oncommand="add_to_bucket();"/>
+				<menuitem label="&staff.cat.opac.mark_for_overlay.label;" accesskey="&staff.cat.opac.mark_for_overlay.accesskey;" id="mark_for_overlay" oncommand="mark_for_overlay();"/>
 				<menuseparator/>
-				<menuitem label="Duplicate in New Tab" id="bib_in_new_tab" oncommand="bib_in_new_tab();"/>
-				<menuitem label="Remove this Frame" id="remove_me" oncommand="remove_me();"/>
+				<menuitem label="&staff.cat.opac.bib_in_new_tab.label;" id="bib_in_new_tab" oncommand="bib_in_new_tab();"/>
+				<menuitem label="&staff.cat.opac.remove_me.label;" id="remove_me" oncommand="remove_me();"/>
 				<menuseparator/>
-				<menuitem label="Set bottom interface as Default" id="default" oncommand="set_default();"/>
-				<menuitem label="Reset Display" id="refresh_me" oncommand="refresh_display(docid,true);"/>
+				<menuitem label="&staff.cat.opac.default.label;" id="default" oncommand="set_default();"/>
+				<menuitem label="&staff.cat.opac.refresh_me.label;" id="refresh_me" oncommand="refresh_display(docid,true);"/>
 				</menupopup>
 				</menu>
 			</menubar>



More information about the open-ils-commits mailing list