Reset $extensionKey when loading each file. This puts the onus on developers
to set the extensionKey once in each file using {assign} or {tsScope}, but
it prevents the extension key from leaking unintentionally to other files,
and it allows developers to handle weird situations explicitly.
(Example weird situation -- using one extension to override another
extension's template; or having multiple extensions share a common
translation key.)
----------------------------------------
* CRM-13580: Set translation domain implicitly in extensions
http://issues.civicrm.org/jira/browse/CRM-13580
}
$this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
+ $this->load_filter('pre', 'resetExtScope');
}
/**
* @return string the string, translated by gettext
*/
function smarty_block_ts($params, $text, &$smarty) {
+ if (!isset($params['domain'])) {
+ $params['domain'] = $smarty->get_template_vars('extensionKey');
+ }
return ts($text, $params);
}
--- /dev/null
+<?php
+
+/**
+ * Wrap every Smarty template in a {crmScope} tag that sets the
+ * variable "extensionKey" to blank.
+ */
+function smarty_prefilter_resetExtScope($tpl_source, &$smarty) {
+ return
+ '{crmScope extensionKey=""}'
+ . $tpl_source
+ .'{/crmScope}';
+}
\ No newline at end of file