mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 21:34:42 +03:00
Create "get_locale_info" function to improve code readability
This commit is contained in:
parent
56357c4d40
commit
47880fa951
@ -84,9 +84,8 @@ class ChatStyle extends AbstractStyle implements StyleInterface
|
||||
$data['mibewVersion'] = MIBEW_VERSION;
|
||||
$data['currentLocale'] = CURRENT_LOCALE;
|
||||
|
||||
$locales = get_locales();
|
||||
$data['rtl'] = isset($locales[CURRENT_LOCALE])
|
||||
&& $locales[CURRENT_LOCALE]['rtl'];
|
||||
$locale_info = get_locale_info(CURRENT_LOCALE);
|
||||
$data['rtl'] = $locale_info && $locale_info['rtl'];
|
||||
|
||||
$data['stylePath'] = MIBEW_WEB_ROOT . '/' . $this->getFilesPath();
|
||||
$data['styleName'] = $this->getName();
|
||||
|
@ -84,9 +84,8 @@ class PageStyle extends AbstractStyle implements StyleInterface
|
||||
$data['mibewVersion'] = MIBEW_VERSION;
|
||||
$data['currentLocale'] = CURRENT_LOCALE;
|
||||
|
||||
$locales = get_locales();
|
||||
$data['rtl'] = isset($locales[CURRENT_LOCALE])
|
||||
&& $locales[CURRENT_LOCALE]['rtl'];
|
||||
$locale_info = get_locale_info(CURRENT_LOCALE);
|
||||
$data['rtl'] = $locale_info && $locale_info['rtl'];
|
||||
|
||||
$data['stylePath'] = MIBEW_WEB_ROOT . '/' . $this->getFilesPath();
|
||||
$data['styleName'] = $this->getName();
|
||||
|
@ -360,6 +360,24 @@ function get_locales()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns locale info by its code.
|
||||
*
|
||||
* It is a wrapper for {@link get_locales()} function and can be used to improve
|
||||
* readability of the code.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return array|false Associative array of locale info or boolean false if the
|
||||
* locale is unknown. See {@link get_locales()} description for details of the
|
||||
* info array keys.
|
||||
*/
|
||||
function get_locale_info($locale)
|
||||
{
|
||||
$locales = get_locales();
|
||||
|
||||
return isset($locales[$locale]) ? $locales[$locale] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load localized messages id some service locale info.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user