From 84a41233cd53091b093954ce7c2edb1470cd98b6 Mon Sep 17 00:00:00 2001 From: Aron Carroll Date: Tue, 7 Aug 2012 14:46:04 +0100 Subject: [PATCH] [#2809] Fix a couple of bad translation calls --- ckan/public/base/javascript/modules/api-info.js | 4 ++-- ckan/public/base/javascript/modules/confirm-delete.js | 10 ++++------ .../base/test/spec/modules/confirm-delete.spec.js | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ckan/public/base/javascript/modules/api-info.js b/ckan/public/base/javascript/modules/api-info.js index 939ed6bdf5e..cc1625bcc75 100644 --- a/ckan/public/base/javascript/modules/api-info.js +++ b/ckan/public/base/javascript/modules/api-info.js @@ -97,7 +97,7 @@ this.ckan.module('api-info', function (jQuery, _) { */ loadTemplate: function () { if (!this.options.template) { - this.sandbox.notify(this.options.i18n.noTemplate); + this.sandbox.notify(this.i18n('noTemplate')); return jQuery.Deferred().reject().promise(); } @@ -125,7 +125,7 @@ this.ckan.module('api-info', function (jQuery, _) { /* error handler when the template fails to load */ _onTemplateError: function () { this.loading(false); - this.sandbox.notify(this.options.i18n.loadError); + this.sandbox.notify(this.i18n('loadError')); } }; }); diff --git a/ckan/public/base/javascript/modules/confirm-delete.js b/ckan/public/base/javascript/modules/confirm-delete.js index eb25a90400c..c12d4d524f1 100644 --- a/ckan/public/base/javascript/modules/confirm-delete.js +++ b/ckan/public/base/javascript/modules/confirm-delete.js @@ -69,18 +69,16 @@ this.ckan.module('confirm-delete', function (jQuery, _) { * Returns the newly created element. */ createModal: function () { - var i18n = this.options.i18n; - if (!this.modal) { var element = this.modal = jQuery(this.options.template); element.on('click', '.btn-primary', this._onConfirmSuccess); element.on('click', '.btn-cancel', this._onConfirmCancel); element.modal({show: false}); - element.find('h3').text(i18n.heading); - element.find('.modal-body').text(i18n.content); - element.find('.btn-primary').text(i18n.confirm); - element.find('.btn-cancel').text(i18n.cancel); + element.find('h3').text(this.i18n('heading')); + element.find('.modal-body').text(this.i18n('content')); + element.find('.btn-primary').text(this.i18n('confirm')); + element.find('.btn-cancel').text(this.i18n('cancel')); } return this.modal; }, diff --git a/ckan/public/base/test/spec/modules/confirm-delete.spec.js b/ckan/public/base/test/spec/modules/confirm-delete.spec.js index cc7ff0c4222..04eddffe57b 100644 --- a/ckan/public/base/test/spec/modules/confirm-delete.spec.js +++ b/ckan/public/base/test/spec/modules/confirm-delete.spec.js @@ -74,14 +74,14 @@ describe('ckan.module.ConfirmDeleteModule()', function () { assert.calledWith(jQuery.fn.modal, {show: false}); }); - it('should insert the localsized strings', function () { + it('should insert the localized strings', function () { var target = this.module.createModal(); var i18n = this.module.options.i18n; - assert.equal(target.find('h3').text(), i18n.heading); - assert.equal(target.find('.modal-body').text(), i18n.content); - assert.equal(target.find('.btn-primary').text(), i18n.confirm); - assert.equal(target.find('.btn-cancel').text(), i18n.cancel); + assert.equal(target.find('h3').text(), i18n.heading.fetch()); + assert.equal(target.find('.modal-body').text(), i18n.content.fetch()); + assert.equal(target.find('.btn-primary').text(), i18n.confirm.fetch()); + assert.equal(target.find('.btn-cancel').text(), i18n.cancel.fetch()); }); });