Browse Source

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
phpnut 19 years ago
parent
commit
762e9ed90c
2 changed files with 39 additions and 47 deletions
  1. 38 46
      cake/basics.php
  2. 1 1
      cake/libs/i18n.php

+ 38 - 46
cake/basics.php

@@ -1084,6 +1084,26 @@
 	}
 /**
  *
+ * 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
  * Returns correct plural form of message identified by $singular and $plural for count $count
  * from domain $domain
@@ -1099,21 +1119,17 @@
 		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 plural message lookup.
+ * Allows you to override the current domain for a single 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.
@@ -1128,30 +1144,28 @@
  * LC_ALL       6
  *
  * @param string $domain
- * @param string $singular
- * @param string $plural
- * @param integer $count
+ * @param string $msg
  * @param string $category
  * @param boolean $return
- * @return plural form of translated string if $return is false string will be echoed
+ * @return translated string if $return is false string will be echoed
  */
-	function __dcn($domain, $singular, $plural, $count, $category, $return = false) {
+	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($singular, $plural, $domain, $category, $count, $dir);
+			echo I18n::translate($msg, null, $domain, $category);
 		} else {
-			return I18n::translate($singular, $plural, $domain, $category, $count, $dir);
+			return I18n::translate($msg, null, $domain, $category);
 		}
 	}
 /**
  *
- * Allows you to override the current domain for a single message lookup.
+ * 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.
@@ -1166,48 +1180,26 @@
  * LC_ALL       6
  *
  * @param string $domain
- * @param string $msg
+ * @param string $singular
+ * @param string $plural
+ * @param integer $count
  * @param string $category
  * @param boolean $return
- * @return translated string if $return is false string will be echoed
+ * @return plural form of translated string if $return is false string will be echoed
  */
-	function __dc($domain, $msg, $category, $return = false) {
+	function __dcn($domain, $singular, $plural, $count, $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);
+			echo I18n::translate($singular, $plural, $domain, $category, $count);
 		} else {
-			return I18n::translate($msg, null, $domain, $category, null, $dir);
+			return I18n::translate($singular, $plural, $domain, $category, $count);
 		}
 	}
 /**
  *
- * 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.
  * Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
  *

+ 1 - 1
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];