Only display locales that are installed on the system

This commit is contained in:
Pierre Rudloff 2017-06-01 23:40:36 +02:00
parent eef3b88ff7
commit b14df412c1

View file

@ -5,6 +5,8 @@
namespace Alltube; namespace Alltube;
use Symfony\Component\Process\ProcessBuilder;
/** /**
* Class used to manage locales. * Class used to manage locales.
*/ */
@ -55,8 +57,14 @@ class LocaleManager
public function getSupportedLocales() public function getSupportedLocales()
{ {
$return = []; $return = [];
$builder = new ProcessBuilder(['locale', '-a']);
$process = $builder->getProcess();
$process->run();
$installedLocales = explode(PHP_EOL, trim($process->getOutput()));
foreach ($this->supportedLocales as $supportedLocale) { foreach ($this->supportedLocales as $supportedLocale) {
$return[] = new Locale($supportedLocale); if (in_array($supportedLocale, $installedLocales)) {
$return[] = new Locale($supportedLocale);
}
} }
return $return; return $return;