[pLog-svn] r5777 - in plog/trunk/class: locale test/tests/locale

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Aug 2 17:15:44 EDT 2007


Author: oscar
Date: 2007-08-02 17:15:44 -0400 (Thu, 02 Aug 2007)
New Revision: 5777

Modified:
   plog/trunk/class/locale/locale.class.php
   plog/trunk/class/test/tests/locale/locale_test.class.php
Log:
Fixed the issue with the new implementation of Locale::pr(), so that we can now use %s or %1$s when there is only one slot for variable parameters in a string.


Modified: plog/trunk/class/locale/locale.class.php
===================================================================
--- plog/trunk/class/locale/locale.class.php	2007-08-02 21:03:14 UTC (rev 5776)
+++ plog/trunk/class/locale/locale.class.php	2007-08-02 21:15:44 UTC (rev 5777)
@@ -288,12 +288,11 @@
 				$param = func_get_arg( 1 ) ;
 				$str = str_replace( "%s", $param, $str );				
 			}
-			else {
-				for( $i = 1; $i < func_num_args(); $i++ ) {
-					$strId = "%{$i}\$s";
-					$param = func_get_arg( $i ) ;
-					$str = str_replace( $strId, $param, $str );
-				}
+			
+			for( $i = 1; $i < func_num_args(); $i++ ) {
+				$strId = "%{$i}\$s";
+				$param = func_get_arg( $i ) ;
+				$str = str_replace( $strId, $param, $str );
 			}
 
 			return $str;

Modified: plog/trunk/class/test/tests/locale/locale_test.class.php
===================================================================
--- plog/trunk/class/test/tests/locale/locale_test.class.php	2007-08-02 21:03:14 UTC (rev 5776)
+++ plog/trunk/class/test/tests/locale/locale_test.class.php	2007-08-02 21:15:44 UTC (rev 5777)
@@ -30,10 +30,12 @@
 			$this->l->_messages["pr_test_1"] = "%1\$s, %2\$s!";
 			$this->l->_messages["pr_test_2"] = "%1\$s, how %2\$s %3\$s today, %4\$s?";
 			$this->l->_messages["pr_test_3"] = "Hello, %s!";
+			$this->l->_messages["pr_test_4"] = "Hello, %1\$s!";
 			
 			$this->assertEquals( "Hello, world!", $this->l->pr( "pr_test_1", "Hello", "world" ));
 			$this->assertEquals( "Hello, how are you today, sir?", $this->l->pr( "pr_test_2", "Hello", "are", "you", "sir" ));			
 			$this->assertEquals( "Hello, world!", $this->l->pr( "pr_test_3", "world" ));
+			$this->assertEquals( "Hello, world!", $this->l->pr( "pr_test_4", "world" ));			
 		}
 		
 		/**



More information about the pLog-svn mailing list