Update arguemnts list of the "getlocal" function.

This commit is contained in:
Dmitriy Simushev 2014-06-05 07:56:08 +00:00
parent 98fe748bef
commit 090166b780
4 changed files with 50 additions and 6 deletions

View File

@ -789,7 +789,10 @@ function chat_start_for_user(
)
);
} else {
$thread->postMessage(Thread::KIND_INFO, getlocal('chat.wait', true));
$thread->postMessage(
Thread::KIND_INFO,
getlocal('chat.wait', null, CURRENT_LOCALE, true)
);
}
}

View File

@ -110,7 +110,7 @@ class MailController extends AbstractController
$history .= message_to_text($msg);
}
$subject = getlocal('mail.user.history.subject', true);
$subject = getlocal('mail.user.history.subject', null, CURRENT_LOCALE, true);
$body = getlocal2(
'mail.user.history.body',
array($thread->userName,

View File

@ -232,9 +232,50 @@ function read_locale_file($path)
);
}
function getlocal($text, $raw = false)
/**
* Returns localized string.
*
* @param string $text A text which should be localized
* @param array $params Indexed array with placeholders.
* @param string $locale Target locale code.
* @param boolean $raw Indicates if the result should be sanitized or not.
* @return string Localized text.
*/
function getlocal($text, $params = null, $locale = CURRENT_LOCALE, $raw = false)
{
return getlocal_($text, CURRENT_LOCALE, $raw);
$string = get_localized_string($text, $locale);
if ($params) {
for ($i = 0; $i < count($params); $i++) {
$string = str_replace("{" . $i . "}", $params[$i], $string);
}
}
return $raw ? $string : sanitize_string($string, 'low', 'moderate');
}
/**
* Return localized string by its key and locale.
*
* Do not use this function manually because it is for internal use only and may
* be removed soon. Use {@link getlocal()} function instead.
*
* @access private
* @param string $string Localization string key.
* @param string $locale Target locale code.
* @return string Localized string.
*/
function get_localized_string($string, $locale)
{
$localized = load_messages($locale);
if (isset($localized[$string])) {
return $localized[$string];
}
if ($locale != 'en') {
return _getlocal($string, 'en');
}
return "!" . $string;
}
function getlocal_($text, $locale, $raw = false)

View File

@ -127,7 +127,7 @@ function invitation_invite($visitor_id, $operator)
);
$thread->postMessage(
Thread::KIND_AGENT,
getlocal("invitation.message", true),
getlocal('invitation.message', null, CURRENT_LOCALE, true),
array(
'name' => $operator_name,
'operator_id' => $operator['operatorid'],
@ -201,7 +201,7 @@ function invitation_reject($visitor_id)
if ($thread) {
$thread->postMessage(
Thread::KIND_FOR_AGENT,
getlocal('chat.visitor.invitation.rejected', true)
getlocal('chat.visitor.invitation.rejected', null, CURRENT_LOCALE, true)
);
}