From cf43b814009c2109c3990e4743ef0738bce5b459 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 19 Dec 2014 12:08:54 +0100 Subject: [PATCH] Use the class namespace instead of the request in Form::translate(Plural) refs #7551 --- library/Icinga/Web/Form.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 205c4e238..f3810903c 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -805,6 +805,20 @@ class Form extends Zend_Form return array(); } + /** + * Return the translation domain for this form + * + * @return string + */ + protected function getTranslationDomain() + { + if (preg_match('@^Icinga\\\\Module\\\\([A-z]+)\\\\.*$@', get_called_class(), $matches) === 1) { + return strtolower($matches[0]); + } + + return $this->getRequest()->getModuleName(); + } + /** * Translate a string * @@ -815,7 +829,7 @@ class Form extends Zend_Form */ protected function translate($text, $context = null) { - return Translator::translate($text, $this->request->getModuleName(), $context); + return Translator::translate($text, $this->getTranslationDomain(), $context); } /** @@ -834,7 +848,7 @@ class Form extends Zend_Form $textSingular, $textPlural, $number, - $this->request->getModuleName(), + $this->getTranslationDomain(), $context ); }