mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 02:18:31 +03:00
Replace HOME_LOCALE const with get_home_locale() func
This commit is contained in:
parent
cca081b5c7
commit
a63215f299
@ -148,7 +148,7 @@ class CommonController extends AbstractController
|
||||
|
||||
$params['left_messages_locale'] = $request->request->get('leftmessageslocale');
|
||||
if (!in_array($params['left_messages_locale'], get_available_locales())) {
|
||||
$params['left_messages_locale'] = HOME_LOCALE;
|
||||
$params['left_messages_locale'] = get_home_locale();
|
||||
}
|
||||
|
||||
if ($params['email'] && !is_valid_email($params['email'])) {
|
||||
|
@ -108,7 +108,7 @@ class WidgetController extends AbstractController
|
||||
// Get operator info
|
||||
$operator = operator_by_id($thread->agentId);
|
||||
$locale = $request->query->get('locale', '');
|
||||
$operator_name = ($locale == HOME_LOCALE)
|
||||
$operator_name = ($locale == get_home_locale())
|
||||
? $operator['vclocalename']
|
||||
: $operator['vccommonname'];
|
||||
|
||||
|
@ -597,7 +597,7 @@ class ThreadProcessor extends ClientSideProcessor
|
||||
// Get message locale
|
||||
$message_locale = Settings::get('left_messages_locale');
|
||||
if (!locale_exists($message_locale)) {
|
||||
$message_locale = HOME_LOCALE;
|
||||
$message_locale = get_home_locale();
|
||||
}
|
||||
|
||||
// Create thread
|
||||
|
@ -81,7 +81,7 @@ class Settings
|
||||
'max_connections_from_one_host' => 10,
|
||||
'thread_lifetime' => 600,
|
||||
'email' => '', /* inbox for left messages */
|
||||
'left_messages_locale' => HOME_LOCALE,
|
||||
'left_messages_locale' => get_home_locale(),
|
||||
'sendmessagekey' => 'center',
|
||||
'enableban' => '0',
|
||||
'enablessl' => '0',
|
||||
|
@ -698,7 +698,7 @@ class Thread
|
||||
*/
|
||||
public function checkForReassign($operator)
|
||||
{
|
||||
$operator_name = ($this->locale == HOME_LOCALE)
|
||||
$operator_name = ($this->locale == get_home_locale())
|
||||
? $operator['vclocalename']
|
||||
: $operator['vccommonname'];
|
||||
|
||||
@ -922,7 +922,7 @@ class Thread
|
||||
{
|
||||
$take_thread = false;
|
||||
$message = '';
|
||||
$operator_name = ($this->locale == HOME_LOCALE)
|
||||
$operator_name = ($this->locale == get_home_locale())
|
||||
? $operator['vclocalename']
|
||||
: $operator['vccommonname'];
|
||||
|
||||
|
@ -23,19 +23,6 @@ use Symfony\Component\Translation\Loader\PoFileLoader;
|
||||
*/
|
||||
define('LOCALE_COOKIE_NAME', 'mibew_locale');
|
||||
|
||||
// Test and set default locales
|
||||
|
||||
/**
|
||||
* Verified value of the $home_locale configuration parameter (see
|
||||
* "configs/default_config.yml" for details)
|
||||
*/
|
||||
define(
|
||||
'HOME_LOCALE',
|
||||
(locale_pattern_check($configs['home_locale']) && locale_exists($configs['home_locale'])
|
||||
? $configs['home_locale']
|
||||
: 'en')
|
||||
);
|
||||
|
||||
function locale_exists($locale)
|
||||
{
|
||||
return file_exists(MIBEW_FS_ROOT . "/locales/$locale/translation.po");
|
||||
@ -136,7 +123,8 @@ function get_user_locale()
|
||||
/**
|
||||
* Returns a value of the default locale.
|
||||
*
|
||||
* Generally it should be used if a user does not provide known lang.
|
||||
* Generally, the locale returned by the function, should be used as a user
|
||||
* locale if does not provide known lang.
|
||||
*
|
||||
* In fact the function returns verified value of "default_locale" variable from
|
||||
* the system configurations file.
|
||||
@ -159,6 +147,33 @@ function get_default_locale()
|
||||
return $default_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of the home locale.
|
||||
*
|
||||
* Generally, the locale returned by the function, should be used as a locale
|
||||
* for operators' native names.
|
||||
*
|
||||
* In fact the function returns verified value of "home_locale" variable from
|
||||
* the system configurations file.
|
||||
*
|
||||
* @return string Locale code.
|
||||
*/
|
||||
function get_home_locale()
|
||||
{
|
||||
static $home_locale = null;
|
||||
|
||||
if (is_null($home_locale)) {
|
||||
$configs = load_system_configs();
|
||||
$is_correct = !empty($configs['home_locale'])
|
||||
&& locale_pattern_check($configs['home_locale'])
|
||||
&& locale_exists($configs['home_locale']);
|
||||
|
||||
$home_locale = $is_correct ? $configs['home_locale'] : 'en';
|
||||
}
|
||||
|
||||
return $home_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves locale for the current request.
|
||||
*
|
||||
|
@ -72,7 +72,10 @@ function group_by_name($name)
|
||||
*/
|
||||
function get_group_name($group)
|
||||
{
|
||||
if (HOME_LOCALE == get_current_locale() || !isset($group['vccommonname']) || !$group['vccommonname']) {
|
||||
$use_local_name = (get_home_locale() == get_current_locale())
|
||||
|| !isset($group['vccommonname'])
|
||||
|| !$group['vccommonname'];
|
||||
if ($use_local_name) {
|
||||
return $group['vclocalname'];
|
||||
} else {
|
||||
return $group['vccommonname'];
|
||||
@ -242,7 +245,7 @@ function group_is_away($group)
|
||||
*/
|
||||
function get_group_description($group)
|
||||
{
|
||||
$use_local_description = HOME_LOCALE == get_current_locale()
|
||||
$use_local_description = (get_home_locale() == get_current_locale())
|
||||
|| !isset($group['vccommondescription'])
|
||||
|| !$group['vccommondescription'];
|
||||
|
||||
|
@ -509,7 +509,7 @@ function is_operator_online($operator_id)
|
||||
*/
|
||||
function get_operator_name($operator)
|
||||
{
|
||||
if (HOME_LOCALE == get_current_locale()) {
|
||||
if (get_home_locale() == get_current_locale()) {
|
||||
return $operator['vclocalename'];
|
||||
} else {
|
||||
return $operator['vccommonname'];
|
||||
|
Loading…
Reference in New Issue
Block a user