From e3d90d6c78a6ce1368e6c7225b5312d63718c06a Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 17 Jan 2015 04:10:39 -0800 Subject: [PATCH] CRM-15832 - crmResource - Fix handling of domains --- Civi/Angular/Manager.php | 5 ++++- Civi/Angular/Page/Modules.php | 1 + js/Common.js | 6 ++++++ js/angular-crmResource/all.js | 2 +- js/angular-crmResource/byModule.js | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Civi/Angular/Manager.php b/Civi/Angular/Manager.php index 4e1afd2b0a..a93c8790ba 100644 --- a/Civi/Angular/Manager.php +++ b/Civi/Angular/Manager.php @@ -181,12 +181,15 @@ class Manager { * Translated strings: array(string $orig => string $translated). */ public function getTranslatedStrings($name) { + $module = $this->getModule($name); $result = array(); $strings = $this->getStrings($name); foreach ($strings as $string) { // TODO: should we pass translation domain based on $module[ext] or $module[tsDomain]? // It doesn't look like client side really supports the domain right now... - $translated = ts($string); + $translated = ts($string, array( + 'domain' => array($module['ext'], NULL), + )); if ($translated != $string) { $result[$string] = $translated; } diff --git a/Civi/Angular/Page/Modules.php b/Civi/Angular/Page/Modules.php index 5f517e5a8b..8141b77e54 100644 --- a/Civi/Angular/Page/Modules.php +++ b/Civi/Angular/Page/Modules.php @@ -36,6 +36,7 @@ class Modules extends \CRM_Core_Page { foreach ($moduleNames as $moduleName) { if (isset($modules[$moduleName])) { $result[$moduleName] = array(); + $result[$moduleName]['domain'] = $modules[$moduleName]['ext']; $result[$moduleName]['js'] = $angular->getScriptUrls($moduleName); $result[$moduleName]['css'] = $angular->getStyleUrls($moduleName); $result[$moduleName]['partials'] = $angular->getPartials($moduleName); diff --git a/js/Common.js b/js/Common.js index 61dbbbe11e..4d2ae26f9d 100644 --- a/js/Common.js +++ b/js/Common.js @@ -1017,6 +1017,12 @@ CRM.strings = CRM.strings || {}; }; }; + CRM.addStrings = function(domain, strings) { + var bucket = (domain == 'civicrm' ? 'strings' : 'strings::' + domain); + CRM[bucket] = CRM[bucket] || {}; + _.extend(CRM[bucket], strings); + }; + /** * @see https://wiki.civicrm.org/confluence/display/CRMDOC/Notification+Reference */ diff --git a/js/angular-crmResource/all.js b/js/angular-crmResource/all.js index ccab58ca13..7c3632fc2a 100644 --- a/js/angular-crmResource/all.js +++ b/js/angular-crmResource/all.js @@ -41,7 +41,7 @@ angular.extend(templates, module.partials); } if (module.strings) { - angular.extend(CRM.strings, module.strings); + CRM.addStrings(module.domain, module.strings); } }); notify(); diff --git a/js/angular-crmResource/byModule.js b/js/angular-crmResource/byModule.js index 9514b2ffdb..c27ad8e57f 100644 --- a/js/angular-crmResource/byModule.js +++ b/js/angular-crmResource/byModule.js @@ -59,7 +59,7 @@ angular.extend(templates, this.data.partials); } if (this.data.strings) { - angular.extend(CRM.strings, this.data.strings); + CRM.addStrings(this.data.domain, this.data.strings); } angular.forEach(this.deferreds, function(deferred) { deferred.resolve(module.data); -- 2.25.1