diff --git a/etemplate/inc/class.etemplate_widget_menupopup.inc.php b/etemplate/inc/class.etemplate_widget_menupopup.inc.php index 06b3dc6846..96470a4aec 100644 --- a/etemplate/inc/class.etemplate_widget_menupopup.inc.php +++ b/etemplate/inc/class.etemplate_widget_menupopup.inc.php @@ -161,10 +161,7 @@ class etemplate_widget_menupopup extends etemplate_widget } if (!$no_lang) { - foreach($options as $value => &$label) - { - $label = lang($label); - } + $options = self::translateOptions($options); } //error_log(__METHOD__."('$name') returning ".array2string($options)); return $options; @@ -567,23 +564,35 @@ class etemplate_widget_menupopup extends etemplate_widget if (!$no_lang) { - foreach($options as $value => &$label) - { - if (!is_array($label)) - { - $label = lang($label); - } - else - { - $label['label'] = lang($label['label']); - if (isset($label['title'])) $label['title'] = lang($label['title']); - } - } + $options = self::translateOptions($options); } //error_log(__METHOD__."('$widget_type', '$legacy_options', ...) returning ".array2string($options)); return $options; } + /** + * Translate options incl. optional title (label is an array with values for keys 'label' and optionally 'title' + * + * @param array $options + * @return $options + */ + public static function translateOptions(array $options) + { + foreach($options as $value => &$label) + { + if (!is_array($label)) + { + $label = lang($label); + } + else + { + $label['label'] = lang($label['label']); + if (isset($label['title'])) $label['title'] = lang($label['title']); + } + } + return $options; + } + /** * internal function to format account-data */