From 762e9ed90cf86ea215bba51e1d551869d61d3678 Mon Sep 17 00:00:00 2001 From: phpnut Date: Mon, 25 Dec 2006 19:38:28 +0000 Subject: [PATCH] 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 --- cake/basics.php | 124 +++++++++++++++++++++------------------------ cake/libs/i18n.php | 2 +- 2 files changed, 59 insertions(+), 67 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index fce730c89..5bafaa24b 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -1082,6 +1082,26 @@ 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 @@ -1099,13 +1119,45 @@ if(!class_exists('I18n')) { uses('i18n'); } - $calledFrom = debug_backtrace(); - $dir = dirname($calledFrom[0]['file']); if($return === false) { - echo I18n::translate($singular, $plural, $domain, 5, $count, $dir);; + echo I18n::translate($singular, $plural, $domain, 5, $count); } 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')) { uses('i18n'); } - $calledFrom = debug_backtrace(); - $dir = dirname($calledFrom[0]['file']); if($return === false) { - echo I18n::translate($singular, $plural, $domain, $category, $count, $dir); + echo I18n::translate($singular, $plural, $domain, $category, $count); } 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. diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index 0e7d3dccf..248519973 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -104,7 +104,7 @@ class I18n extends Object { * @return translated strings. * @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->category = $_this->__categories[$category];