Use the class namespace instead of the request in Form::translate(Plural)
refs #7551
This commit is contained in:
parent
e5d2d4cec2
commit
cf43b81400
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue