diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 8a7c6e888..40b776214 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -380,6 +380,14 @@ class BasicsTest extends CakeTestCase { $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); + $result = __('Some string with %s and a null argument', null); + $expected = 'Some string with %s and a null argument'; + $this->assertEquals($expected, $result); + + $result = __('Some string with multiple %s%s, first beeing null', null, 'arguments'); + $expected = 'Some string with multiple arguments, first beeing null'; + $this->assertEquals($expected, $result); + $result = __('Some string with %s %s', array('multiple', 'arguments')); $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 509dc8f55..81d028e93 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -554,7 +554,7 @@ if (!function_exists('__')) { App::uses('I18n', 'I18n'); $translated = I18n::translate($singular); - if ($args === null) { + if ($args === null && func_num_args() < 3) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 1); @@ -586,7 +586,7 @@ if (!function_exists('__n')) { App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, null, I18n::LC_MESSAGES, $count); - if ($args === null) { + if ($args === null && func_num_args() < 5) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 3); @@ -615,7 +615,7 @@ if (!function_exists('__d')) { } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain); - if ($args === null) { + if ($args === null && func_num_args() < 4) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 2); @@ -648,7 +648,7 @@ if (!function_exists('__dn')) { } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count); - if ($args === null) { + if ($args === null && func_num_args() < 6) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 4); @@ -692,7 +692,7 @@ if (!function_exists('__dc')) { } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain, $category); - if ($args === null) { + if ($args === null && func_num_args() < 5) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 3); @@ -740,7 +740,7 @@ if (!function_exists('__dcn')) { } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, $category, $count); - if ($args === null) { + if ($args === null && func_num_args() < 7) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 5); @@ -780,7 +780,7 @@ if (!function_exists('__c')) { } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, null, $category); - if ($args === null) { + if ($args === null && func_num_args() < 4) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 2);