mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
[ticket/17191] Inject variables from composer.json when loading language files
PHPBB3-17191
This commit is contained in:
@@ -186,6 +186,39 @@ class language_file_loader
|
||||
throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language values from composer.json files
|
||||
*
|
||||
* @param array|string $locales
|
||||
* @return array
|
||||
*/
|
||||
public function get_composer_lang_values(array|string $locales): array
|
||||
{
|
||||
if (!is_array($locales))
|
||||
{
|
||||
$locales = [$locales];
|
||||
}
|
||||
|
||||
$file_helper = new language_file_helper($this->phpbb_root_path);
|
||||
$composer_lang_vars = $file_helper->get_available_languages();
|
||||
|
||||
foreach ($composer_lang_vars as $key => $value)
|
||||
{
|
||||
$composer_lang_vars[$value['iso']] = $value;
|
||||
unset($composer_lang_vars[$key]);
|
||||
}
|
||||
|
||||
foreach ($locales as $locale)
|
||||
{
|
||||
if (isset($composer_lang_vars[$locale]))
|
||||
{
|
||||
return $composer_lang_vars[$locale];
|
||||
}
|
||||
}
|
||||
|
||||
return count($composer_lang_vars) ? array_shift($composer_lang_vars) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads language file
|
||||
*
|
||||
|
Reference in New Issue
Block a user