From b14df412c1232e1fd52fd5bac4c081d4db3eca77 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 1 Jun 2017 23:40:36 +0200 Subject: [PATCH] Only display locales that are installed on the system --- classes/LocaleManager.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index d822588..c426122 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -5,6 +5,8 @@ namespace Alltube; +use Symfony\Component\Process\ProcessBuilder; + /** * Class used to manage locales. */ @@ -55,8 +57,14 @@ class LocaleManager public function getSupportedLocales() { $return = []; + $builder = new ProcessBuilder(['locale', '-a']); + $process = $builder->getProcess(); + $process->run(); + $installedLocales = explode(PHP_EOL, trim($process->getOutput())); foreach ($this->supportedLocales as $supportedLocale) { - $return[] = new Locale($supportedLocale); + if (in_array($supportedLocale, $installedLocales)) { + $return[] = new Locale($supportedLocale); + } } return $return;