mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding fix for I18n when $domain is specified using any of the _ _d*() functions
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4207 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3fb74c2796
commit
762e9ed90c
2 changed files with 59 additions and 67 deletions
124
cake/basics.php
124
cake/basics.php
|
@ -1082,6 +1082,26 @@
|
||||||
return I18n::translate($singular, $plural, null, 5, $count, $dir);
|
return I18n::translate($singular, $plural, null, 5, $count, $dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Allows you to override the current domain for a single message lookup.
|
||||||
|
*
|
||||||
|
* @param string $domain
|
||||||
|
* @param string $msg
|
||||||
|
* @param string $return
|
||||||
|
* @return translated string if $return is false string will be echoed
|
||||||
|
*/
|
||||||
|
function __d($domain, $msg, $return = false) {
|
||||||
|
if(!class_exists('I18n')) {
|
||||||
|
uses('i18n');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($return === false) {
|
||||||
|
echo I18n::translate($msg, null, $domain);
|
||||||
|
} else {
|
||||||
|
return I18n::translate($msg, null, $domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Allows you to override the current domain for a single plural message lookup
|
* Allows you to override the current domain for a single plural message lookup
|
||||||
|
@ -1099,13 +1119,45 @@
|
||||||
if(!class_exists('I18n')) {
|
if(!class_exists('I18n')) {
|
||||||
uses('i18n');
|
uses('i18n');
|
||||||
}
|
}
|
||||||
$calledFrom = debug_backtrace();
|
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
|
||||||
|
|
||||||
if($return === false) {
|
if($return === false) {
|
||||||
echo I18n::translate($singular, $plural, $domain, 5, $count, $dir);;
|
echo I18n::translate($singular, $plural, $domain, 5, $count);
|
||||||
} else {
|
} else {
|
||||||
return I18n::translate($singular, $plural, $domain, 5, $count, $dir);
|
return I18n::translate($singular, $plural, $domain, 5, $count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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 numeric value, instead of the constant name. The values are:
|
||||||
|
* LC_CTYPE 0
|
||||||
|
* LC_NUMERIC 1
|
||||||
|
* LC_TIME 2
|
||||||
|
* LC_COLLATE 3
|
||||||
|
* LC_MONETARY 4
|
||||||
|
* LC_MESSAGES 5
|
||||||
|
* LC_ALL 6
|
||||||
|
*
|
||||||
|
* @param string $domain
|
||||||
|
* @param string $msg
|
||||||
|
* @param string $category
|
||||||
|
* @param boolean $return
|
||||||
|
* @return translated string if $return is false string will be echoed
|
||||||
|
*/
|
||||||
|
function __dc($domain, $msg, $category, $return = false) {
|
||||||
|
if(!class_exists('I18n')) {
|
||||||
|
uses('i18n');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($return === false) {
|
||||||
|
echo I18n::translate($msg, null, $domain, $category);
|
||||||
|
} else {
|
||||||
|
return I18n::translate($msg, null, $domain, $category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1139,73 +1191,13 @@
|
||||||
if(!class_exists('I18n')) {
|
if(!class_exists('I18n')) {
|
||||||
uses('i18n');
|
uses('i18n');
|
||||||
}
|
}
|
||||||
$calledFrom = debug_backtrace();
|
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
|
||||||
|
|
||||||
if($return === false) {
|
if($return === false) {
|
||||||
echo I18n::translate($singular, $plural, $domain, $category, $count, $dir);
|
echo I18n::translate($singular, $plural, $domain, $category, $count);
|
||||||
} else {
|
} else {
|
||||||
return I18n::translate($singular, $plural, $domain, $category, $count, $dir);
|
return I18n::translate($singular, $plural, $domain, $category, $count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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 numeric value, instead of the constant name. The values are:
|
|
||||||
* LC_CTYPE 0
|
|
||||||
* LC_NUMERIC 1
|
|
||||||
* LC_TIME 2
|
|
||||||
* LC_COLLATE 3
|
|
||||||
* LC_MONETARY 4
|
|
||||||
* LC_MESSAGES 5
|
|
||||||
* LC_ALL 6
|
|
||||||
*
|
|
||||||
* @param string $domain
|
|
||||||
* @param string $msg
|
|
||||||
* @param string $category
|
|
||||||
* @param boolean $return
|
|
||||||
* @return translated string if $return is false string will be echoed
|
|
||||||
*/
|
|
||||||
function __dc($domain, $msg, $category, $return = false) {
|
|
||||||
if(!class_exists('I18n')) {
|
|
||||||
uses('i18n');
|
|
||||||
}
|
|
||||||
$calledFrom = debug_backtrace();
|
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
|
||||||
|
|
||||||
if($return === false) {
|
|
||||||
echo I18n::translate($msg, null, $domain, $category, null, $dir);
|
|
||||||
} else {
|
|
||||||
return I18n::translate($msg, null, $domain, $category, null, $dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Allows you to override the current domain for a single message lookup.
|
|
||||||
*
|
|
||||||
* @param string $domain
|
|
||||||
* @param string $msg
|
|
||||||
* @param string $return
|
|
||||||
* @return translated string if $return is false string will be echoed
|
|
||||||
*/
|
|
||||||
function __d($domain, $msg, $return = false) {
|
|
||||||
if(!class_exists('I18n')) {
|
|
||||||
uses('i18n');
|
|
||||||
}
|
|
||||||
$calledFrom = debug_backtrace();
|
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
|
||||||
|
|
||||||
if($return === false) {
|
|
||||||
echo I18n::translate($msg, null, $domain, 5, null, $dir);
|
|
||||||
} else {
|
|
||||||
return I18n::translate($msg, null, $domain, 5, null, $dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* The category argument allows a specific category of the locale settings to be used for fetching a message.
|
* The category argument allows a specific category of the locale settings to be used for fetching a message.
|
||||||
|
|
|
@ -104,7 +104,7 @@ class I18n extends Object {
|
||||||
* @return translated strings.
|
* @return translated strings.
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function translate($singular, $plural = null, $domain = null, $category, $count = null, $directory) {
|
function translate($singular, $plural = null, $domain = null, $category = 5, $count = null, $directory = null) {
|
||||||
$_this =& I18n::getInstance();
|
$_this =& I18n::getInstance();
|
||||||
$_this->category = $_this->__categories[$category];
|
$_this->category = $_this->__categories[$category];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue