From 84757111d18e5f2b85aedb2ab55c123afb396d18 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 20 May 2021 09:35:43 +0200 Subject: [PATCH] ApplicationBootstrap: Deprecate method `listLocales()` --- .../Application/ApplicationBootstrap.php | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index c36dc7edf..3e2b37a79 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -770,27 +770,15 @@ abstract class ApplicationBootstrap /** * List all available locales * - * NOTE: Might be a candidate for a static function in Translator + * @return array Locale list * - * return array Locale list + * @deprecated Use {@see \ipl\I18n\GettextTranslator::listLocales()} instead */ public function listLocales() { - $locales = array(); - if (! $this->hasLocales()) { - return $locales; - } - $localedir = $this->getLocaleDir(); + /** @var GettextTranslator $translator */ + $translator = StaticTranslator::$instance; - $dh = opendir($localedir); - while (false !== ($file = readdir($dh))) { - $filename = $localedir . DIRECTORY_SEPARATOR . $file; - if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $file) && is_dir($filename)) { - $locales[] = $file; - } - } - closedir($dh); - sort($locales); - return $locales; + return $translator->listLocales(); } }