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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
function mtp($domain, $messageId, $messageId2, $n)
|
||||
{
|
||||
return Translator::translatePlural($messageId, $messageId2, $n, $domain);
|
||||
}
|
||||
} else {
|
||||
function t($messageId)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,12 @@ class Translator
|
|||
return $res;
|
||||
}
|
||||
|
||||
public static function translatePlural($msgid1, $msgid2, $n, $domain)
|
||||
{
|
||||
$res = dngettext($domain, $msgid1, $msgid2, $n);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new gettext domain
|
||||
*
|
||||
|
|
|
@ -225,6 +225,20 @@ class ActionController extends Zend_Controller_Action
|
|||
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()
|
||||
{
|
||||
if ($this->isXhr()) {
|
||||
|
|
|
@ -132,6 +132,11 @@ class View extends Zend_View_Abstract
|
|||
return Translator::translate($text, $this->translationDomain);
|
||||
}
|
||||
|
||||
public function translatePlural($text, $text2, $n)
|
||||
{
|
||||
return Translator::translatePlural($text, $text2, $n, $this->translationDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load helpers
|
||||
*/
|
||||
|
|
|
@ -237,6 +237,7 @@ class GettextTranslationHelper
|
|||
'/usr/bin/xgettext',
|
||||
'--language=PHP',
|
||||
'--keyword=translate',
|
||||
'--keyword=translatePlural:1,2',
|
||||
'--keyword=mt:2',
|
||||
'--keyword=t',
|
||||
'--sort-output',
|
||||
|
|
Loading…
Reference in New Issue