-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfunctions.php
43 lines (38 loc) · 943 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
}
}