Remove "get_locale_names" function

This commit is contained in:
Dmitriy Simushev 2014-06-30 11:59:14 +00:00
parent 2f82594a60
commit 7edc74b253
5 changed files with 12 additions and 34 deletions

View File

@ -42,12 +42,12 @@ class CannedMessageController extends AbstractController
// Build list of available locales
$all_locales = get_available_locales();
$locale_names = get_locale_names();
$locales_with_label = array();
foreach ($all_locales as $id) {
$locale_info = get_locale_info($id);
$locales_with_label[] = array(
'id' => $id,
'name' => (isset($locale_names[$id]) ? $locale_names[$id] : $id)
'name' => ($locale_info ? $locale_info['name'] : $id)
);
}
$page['locales'] = $locales_with_label;

View File

@ -43,14 +43,14 @@ class LocaleController extends AbstractController
);
$fs_locales = discover_locales();
$locale_names = get_locale_names();
$available_locales = get_available_locales();
$locales_list = array();
foreach ($fs_locales as $locale) {
$locale_info = get_locale_info($locale);
$locales_list[] = array(
'code' => $locale,
'name' => (isset($locale_names[$locale]) ? $locale_names[$locale] : $locale),
'name' => ($locale_info ? $locale_info['name'] : $locale),
'isDisabled' => !in_array($locale, $available_locales),
);
}

View File

@ -203,13 +203,11 @@ class TranslationController extends AbstractController
*/
protected function getLocaleName($locale)
{
$names = get_locale_names();
$locale_info = get_locale_info($locale);
if (isset($names[$locale])) {
return sprintf('%s (%s)', $names[$locale], $locale);
}
return $locale;
return $locale_info
? sprintf('%s (%s)', $locale_info['name'], $locale)
: $locale;
}
/**

View File

@ -37,12 +37,12 @@ class MailTemplateController extends AbstractController
// Build list of available locales
$all_locales = get_available_locales();
$locale_names = get_locale_names();
$locales_with_label = array();
foreach ($all_locales as $id) {
$locale_info = get_locale_info($id);
$locales_with_label[] = array(
'id' => $id,
'name' => (isset($locale_names[$id]) ? $locale_names[$id] : $id)
'name' => ($locale_info ? $locale_info['name'] : $id)
);
}
$page['locales'] = $locales_with_label;

View File

@ -178,34 +178,14 @@ function get_locale_links()
}
// Attache locale names
$locale_names = get_locale_names();
foreach ($all_locales as $k) {
$locale_links[$k] = isset($locale_names[$k]) ? $locale_names[$k] : $k;
$locale_info = get_locale_info($k);
$locale_links[$k] = $locale_info ? $locale_info['name'] : $k;
}
return $locale_links;
}
/**
* Returns list of human readable locale names.
*
* @return array
*/
function get_locale_names()
{
static $names = false;
if ($names === false) {
$locales = get_locales();
$names = array();
foreach ($locales as $code => $info) {
$names[$code] = $info['name'];
}
}
return $names;
}
/**
* Returns meta data for all known locales.
*