Fix untranslatable strings in several dijits:
authorPasi Kallinen <pasi.kallinen@pttk.fi>
Tue, 9 Jul 2013 06:52:22 +0000 (09:52 +0300)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 14 Nov 2013 22:12:55 +0000 (17:12 -0500)
AutoGrid, EditPane, FlattenerGrid, GridColumnPicker and HoldingCode.

[LFW: One string amended in conflict resolution; commit message edited
to wrap; one line of code moved (this.nls assignment in
GridColumnPicker.js).]

Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/dojo/openils/serial/nls/serial.js
Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js
Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js
Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js
Open-ILS/web/js/dojo/openils/widget/HoldingCode.js
Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js

index c9a5653..9c20c26 100644 (file)
@@ -1,4 +1,13 @@
 {
+    "SEASON_SPRING": "Spring",
+    "SEASON_SUMMER": "Summer",
+    "SEASON_FALL": "Fall",
+    "SEASON_WINTER": "Winter",
+    "SELECT_VALID_CAP": "Have you selected a valid caption and pattern?",
+    "NO_CAP_SUBFIELDS": "No caption subfields in selected caption and pattern",
+    "COMPILE": "Create Holding Code",
+    "ERROR_BLANK_FIELDS": "A valid holding code cannot be produced with any blank fields.",
+    "WIZARD": "Wizard",
     "CREATE_ISSUANCE": "Create Issuance",
     "MODIFY_ISSUANCE": "Modify Issuance",
     "SAVE_SUCCESSFUL": "Save Successful",
index 73f3509..9114aa2 100644 (file)
@@ -9,6 +9,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
     dojo.require('openils.widget.GridColumnPicker');
     dojo.require('openils.widget._GridHelperColumns');
     dojo.require('openils.Util');
+    dojo.requireLocalization('openils.widget', 'AutoFieldWidget');
 
     dojo.declare(
         'openils.widget.AutoGrid',
@@ -58,6 +59,8 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 this.overrideEditWidgetClass = {};
                 this.overrideWidgetArgs = {};
 
+               this.nls = dojo.i18n.getLocalization('openils.widget', 'AutoFieldWidget');
+
                 if(this.editOnEnter) 
                     this._applyEditOnEnter();
                 else if(this.singleEditStyle) 
@@ -69,7 +72,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
 
 
                     var back = dojo.create('a', {
-                        innerHTML : 'Back',  // TODO i18n
+                        innerHTML : self.nls.BACK,
                         style : 'padding-right:6px;',
                         href : 'javascript:void(0);', 
                         onclick : function() { 
@@ -81,7 +84,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                     });
 
                     var forw = dojo.create('a', {
-                        innerHTML : 'Next',  // TODO i18n
+                        innerHTML : self.nls.NEXT,
                         style : 'padding-right:6px;',
                         href : 'javascript:void(0);', 
                         onclick : function() { 
@@ -98,7 +101,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                         dojo.require('openils.widget.PCrudFilterDialog');
                         dojo.place(
                             dojo.create('a', {
-                                innerHTML : 'Filter', // TODO i18n
+                                innerHTML : self.nls.FILTER,
                                 style : 'padding-right:6px;',
                                 href : 'javascript:void(0);', 
                                 onclick : function() { 
index 5bde239..a3d36c0 100644 (file)
@@ -7,6 +7,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
     dojo.require('openils.Util');
     dojo.require('openils.PermaCrud');
     dojo.require('dijit.form.Button');
+    dojo.requireLocalization('openils.widget', 'AutoFieldWidget');
 
     dojo.declare(
         'openils.widget.EditPane',
@@ -44,6 +45,8 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 this.fieldDocs = pcrud.search('fdoc', {fm_class:this.fmClass});
                 */
 
+               this.nls = dojo.i18n.getLocalization('openils.widget', 'AutoFieldWidget');
+
                 var table = this.existingTable;
                 if(!table) {
                     var table = this.table = document.createElement('table');
@@ -190,14 +193,14 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
 
                 var self = this;
                 new dijit.form.Button({
-                    label:'Cancel', // XXX
+                    label: this.nls.CANCEL,
                     onClick : this.onCancel
                 }, cancelSpan);
 
                 if(this.hideSaveButton) return;
 
                 new dijit.form.Button({
-                    label:'Save',  // XXX
+                    label:this.nls.SAVE,
                     onClick: function() {self.performAutoEditAction();}
                 }, applySpan);
             },
@@ -210,15 +213,14 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             // in this edit pane.  If any required value is null, then return
             // an error object.
             mapValues: function (fn) {
-                var e = 0, msg = this.fmIDL.label + ' ';
+                var e = 0, msg = '', lbl = this.fmIDL.label;
                 dojo.forEach(this.fieldList, function (f) {
                     var v, w = f.widget;
                     if ((v = w.getFormattedValue()) === null && w.isRequired()) { e++; }
                     fn(f.name, v);
                 });
                 if (e > 0) {
-                    msg += 'edit pane has ' + e + ' required field(s) that contain no value(s)';
-                    return new Error(msg);
+                    return new Error(dojo.string.substitute(this.nls.REQ_FIELDS_EMPTY, [lbl, e]));
                 }
             },
 
index 4583a97..7548266 100644 (file)
@@ -530,6 +530,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
 
             "_setupLinks": function() {
                 this.linkHolder = new dijit.layout.ContentPane();
+                var localeStrings = this.localeStrings;
                 dojo.place(this.linkHolder.domNode, this.domNode, "before");
 
                 if (this.showLoadFilter) {
@@ -566,7 +567,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                     if (!this.filterAlwaysInDiv) {
                         new dijit.form.Button(
                             {
-                                "label": "Filter", /* XXX i18n */
+                                "label": localeStrings.FILTER,
                                 "onClick": dojo.hitch(
                                     this, function() { this.filterUi.show(); }
                                 )
index 1d32bbe..4fce0b7 100644 (file)
@@ -25,7 +25,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
     dojo.require('openils.Event');
     dojo.require('openils.Util');
     dojo.require('fieldmapper.Fieldmapper');
-
+    dojo.requireLocalization('openils.widget', 'AutoFieldWidget');
 
     dojo.declare('openils.widget.GridColumnPicker', null, {
 
@@ -33,6 +33,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
 
         constructor : function (authtoken, persistKey, grid, structure) {
             var _this = this;
+            this.nls = dojo.i18n.getLocalization('openils.widget', 'AutoFieldWidget');
             this.grid = grid;
             this.persistKey = this.USER_PERSIST_SETTING+'.'+persistKey;
             this.authtoken = authtoken || openils.User.authtoken;
@@ -42,6 +43,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             this.dialog = this.buildDialog();
             this.dialogTable = this.dialog.containerNode.getElementsByTagName('tbody')[0];
 
+
             // replace: called after any sort changes
             this.onSortChange = function(list) {console.log('onSortChange()')}
             // replace:  called after user settings are first retrieved
@@ -118,13 +120,13 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
 
         buildDialog : function() {
             var self = this;
-            
-            // TODO i18n
 
-            var dialog = new dijit.Dialog({title : 'Column Picker'});
+            var dialog = new dijit.Dialog({title : this.nls.COLUMN_PICKER});
             var table = dojo.create('table', {'class':'oils-generic-table', innerHTML : 
-                "<table><thead><tr><th width='30%'>Column</th><th width='23%'>Display</th>" +
-                "<th width='23%'>Auto Width</th><th width='23%'>Sort Priority</th></tr></thead>" +
+                "<table><thead><tr><th width='30%'>" + this.nls.COLUMN + "</th>" +
+               "<th width='23%'>" + this.nls.DISPLAY + "</th>" +
+                "<th width='23%'>" + this.nls.AUTO_WIDTH + "</th>" +
+               "<th width='23%'>" + this.nls.SORT_PRIORITY + "</th></tr></thead>" +
                 "<tbody />"});
 
             var tDiv = dojo.create('div');
@@ -135,8 +137,8 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
 
             var textDiv = dojo.create('div', {style : 'padding:5px; margin-top:5px; border-top:1px solid #333', 
                 innerHTML :
-                    "<i>A Sort Priority of '0' means no sorting is applied.<br/>" +
-                    "<i>Apply a negative Sort Priority for descending sort."});
+                    "<i>" + this.nls.SORT_PRIORITY_ZERO + "<br/>" +
+                    "<i>" + this.nls.SORT_PRIORITY_MINUS});
             
             var wrapper = dojo.create('div');
             wrapper.appendChild(tDiv);
@@ -144,11 +146,11 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             wrapper.appendChild(bDiv);
             dialog.containerNode.appendChild(wrapper);
 
-            var button = new dijit.form.Button({label:'Save'}, 
+            var button = new dijit.form.Button({label: this.nls.SAVE },
                 dojo.query('[name=save_button]', bDiv)[0]);
             button.onClick = function() { dialog.hide(); self.update(true); };
 
-            button = new dijit.form.Button({label:'Cancel'}, 
+            button = new dijit.form.Button({label: this.nls.CANCEL },
                 dojo.query('[name=cancel_button]', bDiv)[0]);
             button.onClick = function() { dialog.hide(); };
 
index 0ee6892..aada2bd 100644 (file)
@@ -3,6 +3,7 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
     dojo.require("dijit.layout.ContentPane");
     dojo.require("dijit.form.DropDownButton");
     dojo.require("dijit.form.TextBox");
+    dojo.requireLocalization('openils.serial', 'serial');
 
     /* XXX These variables and functions preceding the call to dojo.declar()
      * all pollute the window namespace.  They're not written as methods for
@@ -10,16 +11,18 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
      * into there anyway.
      */
 
+    var _localeStrings = dojo.i18n.getLocalization('openils.serial', 'serial');
+
     var _needed_fields = "abcdefghijklm";
     var _season_store = new dojo.data.ItemFileReadStore({
         "data": {
             "identifier": "code",
             "label": "label",
             "items": [
-                {"code": 21, "label": "Spring"},
-                {"code": 22, "label": "Summer"},
-                {"code": 23, "label": "Fall"},
-                {"code": 24, "label": "Winter"}
+                {"code": 21, "label": _localeStrings.SEASON_SPRING},
+                {"code": 22, "label": _localeStrings.SEASON_SUMMER},
+                {"code": 23, "label": _localeStrings.SEASON_FALL},
+                {"code": 24, "label": _localeStrings.SEASON_WINTER}
             ]
         }
     }); /* XXX i18n the above seasons. Also maybe don't
@@ -44,8 +47,7 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
         }
 
         if (!dojo.isArray(pattern_code)) {
-            div.innerHTML =
-                "Have you selected a valid caption and pattern?";/* XXX i18n */
+            div.innerHTML = _localeStrings.SELECT_VALID_CAP;
             return;
         }
 
@@ -59,8 +61,7 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
         }
 
         if (!fields.length) {
-            div.innerHTML = /* XXX i18n (below) */
-                "No caption subfields in seleted caption and pattern";
+            div.innerHTML = _localeStrings.NO_CAP_SUBFIELDS;
             return;
         }
 
@@ -119,15 +120,13 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
 
         new dijit.form.Button(
             {
-                "label": "Create Holding Code",
+                "label": _localeStrings.COMPILE,
                 "onClick": function() {
                     inputs.forEach(
                         function(input) {
                             var value = input.input.attr("value");
                             if (value === null || value === "") {
-                                /* XXX i18n */
-                                alert("A valid holding code cannot be " +
-                                    "produced with any blank fields.");
+                                alert(_localeStrings.ERROR_BLANK_FIELDS);
                             }
                             holding_code.push(input.subfield);
                             holding_code.push(value);
@@ -192,7 +191,7 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
 
                 this.wizard_button = new dijit.form.Button(
                     {
-                        "label": "Wizard" /* XXX i18n */,
+                        "label": _localeStrings.WIZARD,
                         "onClick": function() {
                             _prepare_ttip_dialog(target_div, self);
                         }
index bc77c06..1abeb38 100644 (file)
@@ -1,4 +1,17 @@
 {
+    "NEXT" : "Next",
+    "BACK" : "Back",
+    "FILTER" : "Filter",
+    "CANCEL" : "Cancel",
+    "SAVE" : "Save",
+    "REQ_FIELDS_EMPTY" : "${0} edit pane has ${1} required field(s) that contain no value(s)",
+    "COLUMN_PICKER" : "Column Picker",
+    "COLUMN" : "Column",
+    "DISPLAY" : "Display",
+    "AUTO_WIDTH" : "Auto Width",
+    "SORT_PRIORITY" : "Sort Priority",
+    "SORT_PRIORITY_ZERO" : "A Sort Priority of '0' means no sorting is applied.",
+    "SORT_PRIORITY_MINUS" : "Apply a negative Sort Priority for descending sort.",
     "TRUE" : "True",
     "FALSE" : "False",
     "UNSET" : "Unset",