Use the class namespace instead of the request in Form::translate(Plural)

refs #7551
This commit is contained in:
Johannes Meyer 2014-12-19 12:08:54 +01:00
parent e5d2d4cec2
commit cf43b81400

View File

@ -805,6 +805,20 @@ class Form extends Zend_Form
return array(); 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 * Translate a string
* *
@ -815,7 +829,7 @@ class Form extends Zend_Form
*/ */
protected function translate($text, $context = null) 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, $textSingular,
$textPlural, $textPlural,
$number, $number,
$this->request->getModuleName(), $this->getTranslationDomain(),
$context $context
); );
} }