diff --git a/src/mibew/libs/classes/Mibew/Style/ChatStyle.php b/src/mibew/libs/classes/Mibew/Style/ChatStyle.php index 4bf4f283..7f829e9c 100644 --- a/src/mibew/libs/classes/Mibew/Style/ChatStyle.php +++ b/src/mibew/libs/classes/Mibew/Style/ChatStyle.php @@ -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(); diff --git a/src/mibew/libs/classes/Mibew/Style/PageStyle.php b/src/mibew/libs/classes/Mibew/Style/PageStyle.php index e7c471c2..e680a294 100644 --- a/src/mibew/libs/classes/Mibew/Style/PageStyle.php +++ b/src/mibew/libs/classes/Mibew/Style/PageStyle.php @@ -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(); diff --git a/src/mibew/libs/common/locale.php b/src/mibew/libs/common/locale.php index d34286b8..2eaa0839 100644 --- a/src/mibew/libs/common/locale.php +++ b/src/mibew/libs/common/locale.php @@ -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. *