-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #41568, before remove require_once, move global callable functio…
…ns to new file
- Loading branch information
Showing
3 changed files
with
45 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* Short-named function for string translation, defined in global scope so it's available everywhere. | ||
* | ||
* @param $text string string for translating | ||
* @param $params array an array of additional parameters | ||
* | ||
* @return string the translated string | ||
*/ | ||
function ts($text, $params = array()) { | ||
static $function; | ||
static $locale; | ||
global $tsLocale; | ||
|
||
if (empty($tsLocale)) { | ||
return $text; | ||
} | ||
|
||
if (empty($text)) { | ||
return ''; | ||
} | ||
|
||
$i18n = CRM_Core_I18n::singleton(); | ||
if($locale != $tsLocale){ | ||
$locale = $tsLocale; | ||
if (!empty($i18n->_customTranslateFunction) && $function === NULL) { | ||
if (function_exists($i18n->_customTranslateFunction)) { | ||
$function = $i18n->_customTranslateFunction; | ||
} | ||
else { | ||
$function = FALSE; | ||
} | ||
} | ||
} | ||
|
||
if ($function) { | ||
return $function($text, $params); | ||
} | ||
else { | ||
return $i18n->crm_translate($text, $params); | ||
} | ||
} |