diff --git a/CRM/Core/CodeGen/DAO.php b/CRM/Core/CodeGen/DAO.php index f0c6eec08795..1a47be7cc5db 100644 --- a/CRM/Core/CodeGen/DAO.php +++ b/CRM/Core/CodeGen/DAO.php @@ -20,15 +20,23 @@ class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask { */ private $raw; + /** + * @var string + * translate function name + */ + private $tsFunctionName; + /** * CRM_Core_CodeGen_DAO constructor. * * @param \CRM_Core_CodeGen_Main $config * @param string $name + * @param string $tsFunctionName */ - public function __construct($config, $name) { + public function __construct($config, $name, $tsFunctionName = 'ts') { parent::__construct($config); $this->name = $name; + $this->tsFunctionName = $tsFunctionName; } /** @@ -69,6 +77,7 @@ public function run() { $template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1)); } $template->assign('genCodeChecksum', $this->getTableChecksum()); + $template->assign('tsFunctionName', $this->tsFunctionName); $template->run('dao.tpl', $this->getAbsFileName()); } @@ -88,6 +97,7 @@ public function getRaw() { $template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1)); } $template->assign('genCodeChecksum', 'NEW'); + $template->assign('tsFunctionName', $this->tsFunctionName); $this->raw = $template->fetch('dao.tpl'); } return $this->raw; diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 1919db2b4416..488ec34efddb 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -90,10 +90,10 @@ class {$table.className} extends CRM_Core_DAO {ldelim} 'name' => '{$field.name}', 'type' => {$field.crmType}, {if $field.title} - 'title' => ts('{$field.title}'), + 'title' => {$tsFunctionName}('{$field.title}'), {/if} {if $field.comment} - 'description' => ts('{$field.comment|replace:"'":"\'"}'), + 'description' => {$tsFunctionName}('{$field.comment|replace:"'":"\'"}'), {/if} {if $field.required} 'required' => {$field.required|strtoupper}, @@ -148,7 +148,7 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $field.html} 'html' => array( {foreach from=$field.html item=val key=key} - '{$key}' => {if $key eq 'label'}ts("{$val}"){else}'{$val}'{/if}, + '{$key}' => {if $key eq 'label'}{$tsFunctionName}("{$val}"){else}'{$val}'{/if}, {/foreach} ), {/if}