diff --git a/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php b/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php index 4c6f922b7ccdd5ba39878adefe06a4e9b78afff0..ad9e7f6c0fd21a98537e39153783aea24dea3bc6 100644 --- a/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php +++ b/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php @@ -49,11 +49,11 @@ class ExtendedIni implements FileLoaderInterface protected $pathStack; /** - * Fallback locale to use for language strings missing from selected file. + * Fallback locales to use for language strings missing from selected file. * - * @var string + * @var string[] */ - protected $fallbackLocale; + protected $fallbackLocales; /** * List of files loaded during the current run -- avoids infinite loops and @@ -66,15 +66,18 @@ class ExtendedIni implements FileLoaderInterface /** * Constructor * - * @param array $pathStack List of directories to search for language - * files. - * @param string $fallbackLocale Fallback locale to use for language strings - * missing from selected file. + * @param array $pathStack List of directories to search for + * language files. + * @param string|string[] $fallbackLocales Fallback locale(s) to use for language + * strings missing from selected file. */ - public function __construct($pathStack = array(), $fallbackLocale = null) + public function __construct($pathStack = array(), $fallbackLocales = null) { $this->pathStack = $pathStack; - $this->fallbackLocale = $fallbackLocale; + $this->fallbackLocales = $fallbackLocales; + if (!empty($this->fallbackLocales) && !is_array($this->fallbackLocales)) { + $this->fallbackLocales = array($this->fallbackLocales); + } } /** @@ -96,10 +99,12 @@ class ExtendedIni implements FileLoaderInterface $data = $this->loadLanguageFile($locale . '.ini'); // Load fallback data, if any: - if (!empty($this->fallbackLocale)) { - $newData = $this->loadLanguageFile($this->fallbackLocale . '.ini'); - $newData->merge($data); - $data = $newData; + if (!empty($this->fallbackLocales)) { + foreach ($this->fallbackLocales as $fallbackLocale) { + $newData = $this->loadLanguageFile($fallbackLocale . '.ini'); + $newData->merge($data); + $data = $newData; + } } return $data; diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index fb8f70f5e98e15807758101961e6469d421a0b83..d21a0a64d160a9b079febf8701792f2dd7ac643b 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -433,10 +433,13 @@ class Factory APPLICATION_PATH . '/languages', LOCAL_OVERRIDE_DIR . '/languages' ); + $fallbackLocales = $config->Site->language == 'en' + ? 'en' + : array($config->Site->language, 'en'); $translator->getPluginManager()->setService( 'extendedini', new \VuFind\I18n\Translator\Loader\ExtendedIni( - $pathStack, $config->Site->language + $pathStack, $fallbackLocales ) );