Internationalize the JavaScript portion of the "Manage Authorities" interface
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 3 Jan 2011 03:54:04 +0000 (03:54 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 3 Jan 2011 03:54:04 +0000 (03:54 +0000)
We can use the dojo i18n infrastructure to support translations of the
"Manage Authorities" interface, but unfortunately we still don't have
a TT2 solution for i18n. Still, better to do what we can.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19093 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/authority/nls/authority.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/cat/authority/list.js
build/i18n/Makefile

diff --git a/Open-ILS/web/js/dojo/openils/authority/nls/authority.js b/Open-ILS/web/js/dojo/openils/authority/nls/authority.js
new file mode 100644 (file)
index 0000000..732b433
--- /dev/null
@@ -0,0 +1,19 @@
+{
+    "MASTER_RECORD": "Master",
+    "TARGET_RECORD": "Target",
+    "MENU_EDIT": "Edit",
+    "MENU_MERGE": "Mark for Merge",
+    "MENU_DELETE": "Delete",
+    "CONFIRM_DELETE_TITLE": "Delete the authority record: \"${0}\"?",
+    "LINKED_BIBS": "Number of linked bibliographic records: ${0}",
+    "CANCEL": "Cancel",
+    "ACTIONS": "Actions",
+    "DELETE": "Delete",
+    "VIEW_MARC": "View MARC",
+    "HIDE_MARC": "Hide MARC",
+    "CONFIRM_DELETE_PROMPT": "Confirm deletion of record # ${0}",
+    "CONFIRM_DELETE_RESULT": "Deleted authority record # ${0}.",
+    "SAVE": "Save",
+    "SAVE_RESULT_SUCCESS": "Record was saved.",
+    "MERGE_RESULT_SUCCESS": "Record merge is complete."
+}
index 6c24621..98baeff 100644 (file)
@@ -14,6 +14,8 @@ dojo.require('openils.CGI');
 dojo.require('openils.PermaCrud');
 dojo.require('openils.XUL');
 dojo.require('openils.widget.OrgUnitFilteringSelect');
+dojo.requireLocalization("openils.authority", "authority");
+var auth_strings = dojo.i18n.getLocalization("openils.authority", "authority");
 
 var cgi = new openils.CGI();
 
@@ -68,7 +70,7 @@ function displayAuthorities(data) {
             if (auth_rec) {
                 loadMarcEditor(pcrud, auth_rec);
             }
-        }, "label":"Edit"}).placeAt(auth_menu, "first");
+        }, "label":auth_strings.MENU_EDIT}).placeAt(auth_menu, "first");
 
         // "Merge" menu item
         new dijit.MenuItem({"id": "merge_" + auth.id, "onClick":function(){
@@ -81,15 +83,15 @@ function displayAuthorities(data) {
             var mergeRole = '<td style="border: 1px solid black; padding-left: 0.5em; padding-right: 1em;">';
             var isTarget = dojo.query('.toMerge').length;
             if (isTarget) {
-                mergeRole += 'Target</td>';
+                mergeRole += auth_strings.TARGET_RECORD + '</td>';
             } else {
-                mergeRole += 'Master</td>';
+                mergeRole += auth_strings.MASTER_RECORD + '</td>';
             }
 
             dojo.place('<tr class="toMerge" id="toMerge_' + auth.id + '"><td>' + mergeRole + '</td><td  style="border: 1px solid black;" id="mergeMeta_' + auth.id + '"></td><td style="border: 1px solid black; padding-left: 1em; padding-right: 1em;" >' + auth.text + '</td></tr>', 'mergebox-tbody', 'last');
             dojo.place('<span class="authmeta" style="font-family: monospace;">' + auth.name + ' ' + auth.ind1 + auth.ind2 + '</span>', 'mergeMeta_' + auth.id, 'last');
             dojo.removeClass('mergebox-div', 'hidden');
-        }, "label":"Mark for Merge"}).placeAt(auth_menu, "last");
+        }, "label":auth_strings.MENU_MERGE}).placeAt(auth_menu, "last");
 
         // "Delete" menu item
         new dijit.MenuItem({
@@ -112,34 +114,36 @@ function displayAuthorities(data) {
                 });
 
                 if (!delDlg) {
-                    var content = '<div>Delete the authority record: "' + auth.text + '"?</div>';
+                    var content = '<div>' + dojo.string.substitute(auth_strings.CONFIRM_DELETE_TITLE, [auth.text]) + '</div>';
                     if (parseInt(linkedBibs) > 0) {
-                        content = "<div id='delAuthSum_" + auth.id + "'>Number of linked bibliographic records: " + linkedBibs + "</div>";
+                        content = "<div id='delAuthSum_" + auth.id + "'>"
+                            + dojo.string.substitute(auth_strings.LINKED_BIBS, [linkedBibs])
+                            + "</div>";
                     }
                     content += "<div id='authMARC" + auth.id + "' style='width: 100%; display:none;'>";
                     content += "<hr style='width: 100%;' />";
                     content += marcToHTML(auth_rec.marc());
                     content += "</div><hr style='width: 100%;' /><div>";
-                    content += "<input type='button' dojoType='dijit.form.Button' label='Cancel' onClick='cancelDelete(" + auth.id + ")'/>";
-                    content += "<input type='button' dojoType='dijit.form.Button' label='Delete' onClick='confirmDelete(" + auth.id + ")'/>";
+                    content += "<input type='button' dojoType='dijit.form.Button' label='" + auth_strings.CANCEL + "' onClick='cancelDelete(" + auth.id + ")'/>";
+                    content += "<input type='button' dojoType='dijit.form.Button' label='" + auth_strings.DELETE + "' onClick='confirmDelete(" + auth.id + ")'/>";
                     content += "<input id='viewMARC" + auth.id + "' type='button' "
                         + "style='float:right;' dojoType='dijit.form.Button' "
-                        + "label='View MARC' onClick='viewMARC(" + auth.id + ")'/>";
+                        + "label='" + auth_strings.VIEW_MARC + "' onClick='viewMARC(" + auth.id + ")'/>";
                     content += "<input id='hideMARC" + auth.id + "' type='button' "
                         + "style='display: none; float:right;' dojoType='dijit.form.Button' "
-                        + "label='Hide MARC' onClick='hideMARC(" + auth.id + ")'/>";
+                        + "label='" + auth_strings.HIDE_MARC + "' onClick='hideMARC(" + auth.id + ")'/>";
                     content += "</div>";
                     delDlg = new dijit.Dialog({
                         "id":"delDialog_" + auth.id,
-                        "title":"Confirm deletion of record # " + auth.id,
+                        "title": dojo.string.substitute(auth_strings.CONFIRM_DELETE_PROMPT, [auth.id]),
                         "content": content
                     });
                 }
                 delDlg.show();
 
-        }, "label":"Delete"}).placeAt(auth_menu, "last");
+        }, "label":auth_strings.DELETE}).placeAt(auth_menu, "last");
 
-        auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label:"Actions", id:"menu" + auth.id});
+        auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label: auth_strings.ACTIONS, id:"menu" + auth.id});
         auth_mb.placeAt("auth" + auth.id, "first");
         auth_menu.startup();
     });
@@ -193,7 +197,7 @@ function confirmDelete(recId) {
     var auth_rec = pcrud.retrieve("are", recId);
     if (auth_rec) {
         pcrud.eliminate(auth_rec);
-        dijit.byId("delDialog_" + recId).attr("content", "Deleted authority record # " + recId);
+        dijit.byId("delDialog_" + recId).attr("content", dojo.string.substitute(auth_strings.CONFIRM_DELETE_RESULT, [recId]));
         setTimeout(function() {
             dijit.byId("delDialog_" + recId).hide();
         }, 3000);
@@ -240,13 +244,13 @@ function loadMarcEditor(pcrud, rec) {
     win.xulG = {
         "record": {"marc": rec.marc(), "rtype": "are"},
         "save": {
-            "label": "Save",
+            "label": auth_strings.SAVE,
             "func": function(xmlString) {
                 rec.marc(xmlString);
                 rec.edit_date('now');
                 rec.ischanged(true);
                 pcrud.update(rec);
-                alert("Record was saved");
+                alert(auth_strings.SAVE_RESULT_SUCCESS);
                 win.close();
             }
         },
@@ -349,7 +353,7 @@ function mergeRecords() {
         {   async: false,
             params: [openils.User.authtoken, records.shift(), records],
             oncomplete : function(r) {
-                alert("Record merge is complete.");
+                alert(auth_strings.MERGE_RESULT_SUCCESS);
                 clearMergeRecords();
                 displayRecords();
             }
index 28ae7fc..eec71f5 100644 (file)
@@ -9,6 +9,7 @@ SERVER_PROPSDIR=../../Open-ILS/xul/staff_client/server/locale
 DOJO_LOCALE := $(shell echo ${LOCALE} | tr '[:upper:]-' '[:lower:]/')
 DOJO_ACQ_SRC=../../Open-ILS/web/js/dojo/openils/acq/nls
 DOJO_ACTOR_SRC=../../Open-ILS/web/js/dojo/openils/actor/nls
+DOJO_AUTHORITY_SRC=../../Open-ILS/web/js/dojo/openils/authority/nls
 DOJO_BOOKING_SRC=../../Open-ILS/web/js/dojo/openils/booking/nls
 DOJO_CIRC_SRC=../../Open-ILS/web/js/dojo/openils/circ/nls
 DOJO_CON_SRC=../../Open-ILS/web/js/dojo/openils/conify/nls
@@ -149,6 +150,7 @@ dtds2pot:
 dojo2pot:
        @scripts/dojo_resource.py --pot $(DOJO_ACQ_SRC)/acq.js --output $(PO)/acq.js/acq.js.pot
        @scripts/dojo_resource.py --pot $(DOJO_ACTOR_SRC)/register.js --output $(PO)/register.js/register.js.pot
+       @scripts/dojo_resource.py --pot $(DOJO_AUTHORITY_SRC)/authority.js --output $(PO)/authority.js/authority.js.pot
        @scripts/dojo_resource.py --pot $(DOJO_BOOKING_SRC)/capture.js --output $(PO)/capture.js/capture.js.pot
        @scripts/dojo_resource.py --pot $(DOJO_BOOKING_SRC)/pickup_and_return.js --output $(PO)/pickup_and_return.js/pickup_and_return.js.pot
        @scripts/dojo_resource.py --pot $(DOJO_BOOKING_SRC)/pull_list.js --output $(PO)/pull_list.js/pull_list.js.pot
@@ -280,6 +282,8 @@ install: updatepo project fmidl2fmidlent fmidlpo2entity-en
        cp $(PROJECT)/$(LOCALE)/acq.js $(DOJO_ACQ_SRC)/$(DOJO_LOCALE)/acq.js
        mkdir -p $(DOJO_ACTOR_SRC)/$(DOJO_LOCALE)
        cp $(PROJECT)/$(LOCALE)/register.js $(DOJO_ACTOR_SRC)/$(DOJO_LOCALE)/register.js
+       mkdir -p $(DOJO_AUTHORITY_SRC)/$(DOJO_LOCALE)
+       cp $(PROJECT)/$(LOCALE)/authority.js $(DOJO_AUTHORITY_SRC)/$(DOJO_LOCALE)/authority.js
        mkdir -p $(DOJO_BOOKING_SRC)/$(DOJO_LOCALE)
        cp $(PROJECT)/$(LOCALE)/capture.js $(DOJO_BOOKING_SRC)/$(DOJO_LOCALE)/capture.js
        cp $(PROJECT)/$(LOCALE)/pickup_and_return.js $(DOJO_BOOKING_SRC)/$(DOJO_LOCALE)/pickup_and_return.js