diff --git a/classes/plugins/ThemePlugin.inc.php b/classes/plugins/ThemePlugin.inc.php index 5d0ef15afe6..aeedd2f283e 100644 --- a/classes/plugins/ThemePlugin.inc.php +++ b/classes/plugins/ThemePlugin.inc.php @@ -460,6 +460,32 @@ public function getOption($name) { return isset($option->default) ? $option->default : null; } + /** + * Get the localized value of an option + * + * Modelled on DataObject::getLocalizedData() + * + * @param string $name The name of the option + */ + public function getLocalizedOption($name) + { + $value = $this->getOption($name); + + if (!is_array($value)) { + return null; + } + + $localePrecedence = AppLocale::getLocalePrecedence(); + foreach ($localePrecedence as $localeKey) { + if (is_array($value) && !empty($value[$localeKey])) { + return $value[$localeKey]; + } + } + + // Fallback: Get the first available piece of data + return $value[array_key_first($value)]; + } + /** * Get an option's configuration settings *