Commit | Line | Data |
---|---|---|
4bcd4c62 TO |
1 | <?php |
2 | /** | |
3 | * @file | |
4 | * | |
5 | * Build a list of available translations. | |
6 | */ | |
7 | ||
8 | if (!defined('CIVI_SETUP')) { | |
9 | exit("Installation plugins must only be loaded by the installer.\n"); | |
10 | } | |
11 | ||
12 | \Civi\Setup::dispatcher() | |
13 | ->addListener('civi.setup.init', function (\Civi\Setup\Event\InitEvent $e) { | |
14 | \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'init')); | |
15 | ||
16 | /** | |
17 | * @var \Civi\Setup\Model $m | |
18 | */ | |
19 | $m = $e->getModel(); | |
20 | ||
21 | $langs = NULL; | |
22 | require implode(DIRECTORY_SEPARATOR, [$m->srcPath, 'install', 'langs.php']); | |
23 | foreach ($langs as $locale => $_) { | |
24 | if ($locale == 'en_US') { | |
25 | continue; | |
26 | } | |
27 | if (!file_exists(implode(DIRECTORY_SEPARATOR, array($m->srcPath, 'sql', "civicrm_data.$locale.mysql")))) { | |
28 | unset($langs[$locale]); | |
29 | } | |
30 | } | |
31 | ||
32 | $m->setField('lang', 'options', $langs); | |
33 | ||
34 | }, \Civi\Setup::PRIORITY_PREPARE); |