mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
Experimental Plural Translation Implementation
Personal BACKUP
This commit is contained in:
parent
3615b96093
commit
583fd46f15
@ -924,4 +924,9 @@ class Module
|
|||||||
{
|
{
|
||||||
return mt($this->name, $string);
|
return mt($this->name, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function translatePlural($string, $string2, $n)
|
||||||
|
{
|
||||||
|
return mtp($this->name, $string, $string2, $n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,10 @@ if (extension_loaded('gettext')) {
|
|||||||
{
|
{
|
||||||
return Translator::translate($messageId, $domain);
|
return Translator::translate($messageId, $domain);
|
||||||
}
|
}
|
||||||
|
function mtp($domain, $messageId, $messageId2, $n)
|
||||||
|
{
|
||||||
|
return Translator::translatePlural($messageId, $messageId2, $n, $domain);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
function t($messageId)
|
function t($messageId)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,12 @@ class Translator
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function translatePlural($msgid1, $msgid2, $n, $domain)
|
||||||
|
{
|
||||||
|
$res = dngettext($domain, $msgid1, $msgid2, $n);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new gettext domain
|
* Register a new gettext domain
|
||||||
*
|
*
|
||||||
|
@ -225,6 +225,20 @@ class ActionController extends Zend_Controller_Action
|
|||||||
return Translator::translate($text, $this->view->translationDomain);
|
return Translator::translate($text, $this->view->translationDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate a plural string
|
||||||
|
*
|
||||||
|
* @param $msgid1
|
||||||
|
* @param $msgid2
|
||||||
|
* @param $n
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function translatePlural($msgid1, $msgid2, $n)
|
||||||
|
{
|
||||||
|
return Translator::translatePlural($msgid1, $msgid2, $n, $this->view->translationDomain);
|
||||||
|
}
|
||||||
|
|
||||||
protected function ignoreXhrBody()
|
protected function ignoreXhrBody()
|
||||||
{
|
{
|
||||||
if ($this->isXhr()) {
|
if ($this->isXhr()) {
|
||||||
|
@ -132,6 +132,11 @@ class View extends Zend_View_Abstract
|
|||||||
return Translator::translate($text, $this->translationDomain);
|
return Translator::translate($text, $this->translationDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function translatePlural($text, $text2, $n)
|
||||||
|
{
|
||||||
|
return Translator::translatePlural($text, $text2, $n, $this->translationDomain);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load helpers
|
* Load helpers
|
||||||
*/
|
*/
|
||||||
|
@ -237,6 +237,7 @@ class GettextTranslationHelper
|
|||||||
'/usr/bin/xgettext',
|
'/usr/bin/xgettext',
|
||||||
'--language=PHP',
|
'--language=PHP',
|
||||||
'--keyword=translate',
|
'--keyword=translate',
|
||||||
|
'--keyword=translatePlural:1,2',
|
||||||
'--keyword=mt:2',
|
'--keyword=mt:2',
|
||||||
'--keyword=t',
|
'--keyword=t',
|
||||||
'--sort-output',
|
'--sort-output',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user