mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add the other translation shortcuts for context support
This commit is contained in:
parent
0aabc5d910
commit
fbeb8fe26b
2 changed files with 204 additions and 1 deletions
|
@ -380,6 +380,13 @@ class ExtractTask extends AppShell {
|
|||
$this->_parse('__dcn', array('domain', 'singular', 'plural', 'count', 'category'));
|
||||
|
||||
$this->_parse('__x', array('context', 'singular'));
|
||||
$this->_parse('__xn', array('context', 'singular', 'plural'));
|
||||
$this->_parse('__dx', array('domain', 'context', 'singular'));
|
||||
$this->_parse('__dxc', array('domain', 'context', 'singular', 'category'));
|
||||
$this->_parse('__dxn', array('domain', 'context', 'singular', 'plural'));
|
||||
$this->_parse('__dxcn', array('domain', 'context', 'singular', 'plural', 'count', 'category'));
|
||||
$this->_parse('__xc', array('context', 'singular', 'category'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -800,7 +800,203 @@ if (!function_exists('__x')) {
|
|||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($singular, null, null, null, null, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 1));
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__xn')) {
|
||||
|
||||
/**
|
||||
* Returns correct plural form of message identified by $singular and $plural for count $count.
|
||||
* Some languages have more than one form for plural messages dependent on the count.
|
||||
*
|
||||
* @param string $context Context of the text
|
||||
* @param string $singular Singular text to translate
|
||||
* @param string $plural Plural text
|
||||
* @param integer $count Count
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return mixed plural form of translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__n
|
||||
*/
|
||||
function __xn($context, $singular, $plural, $count, $args = null) {
|
||||
if (!$singular) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($singular, $plural, null, I18n::LC_MESSAGES, $count, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__dx')) {
|
||||
|
||||
/**
|
||||
* Allows you to override the current domain for a single message lookup.
|
||||
*
|
||||
* @param string $domain Domain
|
||||
* @param string $context Context of the text
|
||||
* @param string $msg String to translate
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d
|
||||
*/
|
||||
function __dx($domain, $context, $msg, $args = null) {
|
||||
if (!$msg) {
|
||||
return;
|
||||
}
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($msg, null, $domain, null, null, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__dxn')) {
|
||||
|
||||
/**
|
||||
* Allows you to override the current domain for a single plural message lookup.
|
||||
* Returns correct plural form of message identified by $singular and $plural for count $count
|
||||
* from domain $domain.
|
||||
*
|
||||
* @param string $domain Domain
|
||||
* @param string $context Context of the text
|
||||
* @param string $singular Singular string to translate
|
||||
* @param string $plural Plural
|
||||
* @param integer $count Count
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return plural form of translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn
|
||||
*/
|
||||
function __dxn($domain, $context, $singular, $plural, $count, $args = null) {
|
||||
if (!$singular) {
|
||||
return;
|
||||
}
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 5));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__dxc')) {
|
||||
|
||||
/**
|
||||
* Allows you to override the current domain for a single message lookup.
|
||||
* It also allows you to specify a category.
|
||||
*
|
||||
* The category argument allows a specific category of the locale settings to be used for fetching a message.
|
||||
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
|
||||
*
|
||||
* Note that the category must be specified with a class constant of I18n, instead of the constant name. The values are:
|
||||
*
|
||||
* - LC_ALL I18n::LC_ALL
|
||||
* - LC_COLLATE I18n::LC_COLLATE
|
||||
* - LC_CTYPE I18n::LC_CTYPE
|
||||
* - LC_MONETARY I18n::LC_MONETARY
|
||||
* - LC_NUMERIC I18n::LC_NUMERIC
|
||||
* - LC_TIME I18n::LC_TIME
|
||||
* - LC_MESSAGES I18n::LC_MESSAGES
|
||||
*
|
||||
* @param string $domain Domain
|
||||
* @param string $context Context of the text
|
||||
* @param string $msg Message to translate
|
||||
* @param integer $category Category
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc
|
||||
*/
|
||||
function __dxc($domain, $context, $msg, $category, $args = null) {
|
||||
if (!$msg) {
|
||||
return;
|
||||
}
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($msg, null, $domain, $category, null, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__dxcn')) {
|
||||
|
||||
/**
|
||||
* Allows you to override the current domain for a single plural message lookup.
|
||||
* It also allows you to specify a category.
|
||||
* Returns correct plural form of message identified by $singular and $plural for count $count
|
||||
* from domain $domain.
|
||||
*
|
||||
* The category argument allows a specific category of the locale settings to be used for fetching a message.
|
||||
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
|
||||
*
|
||||
* Note that the category must be specified with a class constant of I18n, instead of the constant name. The values are:
|
||||
*
|
||||
* - LC_ALL I18n::LC_ALL
|
||||
* - LC_COLLATE I18n::LC_COLLATE
|
||||
* - LC_CTYPE I18n::LC_CTYPE
|
||||
* - LC_MONETARY I18n::LC_MONETARY
|
||||
* - LC_NUMERIC I18n::LC_NUMERIC
|
||||
* - LC_TIME I18n::LC_TIME
|
||||
* - LC_MESSAGES I18n::LC_MESSAGES
|
||||
*
|
||||
* @param string $domain Domain
|
||||
* @param string $context Context of the text
|
||||
* @param string $singular Singular string to translate
|
||||
* @param string $plural Plural
|
||||
* @param integer $count Count
|
||||
* @param integer $category Category
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return plural form of translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn
|
||||
*/
|
||||
function __dxcn($domain, $context, $singular, $plural, $count, $category, $args = null) {
|
||||
if (!$singular) {
|
||||
return;
|
||||
}
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($singular, $plural, $domain, $category, $count, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 6));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('__xc')) {
|
||||
|
||||
/**
|
||||
* The category argument allows a specific category of the locale settings to be used for fetching a message.
|
||||
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
|
||||
*
|
||||
* Note that the category must be specified with a class constant of I18n, instead of the constant name. The values are:
|
||||
*
|
||||
* - LC_ALL I18n::LC_ALL
|
||||
* - LC_COLLATE I18n::LC_COLLATE
|
||||
* - LC_CTYPE I18n::LC_CTYPE
|
||||
* - LC_MONETARY I18n::LC_MONETARY
|
||||
* - LC_NUMERIC I18n::LC_NUMERIC
|
||||
* - LC_TIME I18n::LC_TIME
|
||||
* - LC_MESSAGES I18n::LC_MESSAGES
|
||||
*
|
||||
* @param string $context Context of the text
|
||||
* @param string $msg String to translate
|
||||
* @param integer $category Category
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c
|
||||
*/
|
||||
function __xc($context, $msg, $category, $args = null) {
|
||||
if (!$msg) {
|
||||
return;
|
||||
}
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($msg, null, null, $category, null, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 3));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue