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

Jon Daley plogworld at jon.limedaley.com
Thu Aug 2 21:49:20 EDT 2007


 	So, I guess you like the %1$s syntax - I was hoping it would just 
go away.  Maybe we don't care / shouldn't ever happen bugs in the locale 
file, but having a string with a %s and a %1$s will do the wrong thing.

On Thu, 2 Aug 2007, oscar at devel.lifetype.net wrote:

> 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" ));
> 		}
>
> 		/**
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>

-- 
Jon Daley
http://jon.limedaley.com/

What good is it for a man to gain the whole world, yet forfeit his soul?
-- Jesus Christ


More information about the pLog-svn mailing list