From ed7225e6d86ec622c1d55aa7e50fedadff852705 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 2 May 2014 18:24:36 -0700 Subject: [PATCH] CRM-13580 - change signature of CRM.ts --- js/Common.js | 13 ++++++------- tests/qunit/crm-translate/test.js | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/js/Common.js b/js/Common.js index caa981d68d..a68554b4e5 100644 --- a/js/Common.js +++ b/js/Common.js @@ -731,15 +731,14 @@ CRM.validate = CRM.validate || { return dialog.dialog(settings).trigger('crmLoad'); }; - /** eg CRM.translate('org.example.myext', function(ts){ ... }); */ - CRM.translate = function(domain, callback) { - "use strict"; - var altTs = function(message, options) { - options = options || {}; - options.domain = domain; + /** provides a local copy of ts for a domain */ + CRM.ts = function(domain) { + return function(message, options) { + if (domain) { + options = $.extend(options || {}, {domain: domain}); + } return ts(message, options); }; - callback(altTs); }; /** diff --git a/tests/qunit/crm-translate/test.js b/tests/qunit/crm-translate/test.js index 44fe01cb04..6ba3cd9eb2 100644 --- a/tests/qunit/crm-translate/test.js +++ b/tests/qunit/crm-translate/test.js @@ -4,8 +4,8 @@ test('ts()', function() { equal(ts('One, two, three'), "Un, deux, trois", "We expect translations to work"); }); -test('CRM.translate()', function() { - CRM.translate('org.example.foo', function(ts){ +test('CRM.ts()', function() { + (function (ts) { equal(ts('One, two, three'), "Un, deux, trois", "We expect translations to work"); - }); + }(CRM.ts('org.example.foo'))); }); -- 2.25.1