[pLog-svn] r5768 - in plog/trunk/class: locale test/tests/locale
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Aug 1 16:39:08 EDT 2007
Author: oscar
Date: 2007-08-01 16:39:07 -0400 (Wed, 01 Aug 2007)
New Revision: 5768
Modified:
plog/trunk/class/locale/locale.class.php
plog/trunk/class/test/tests/locale/locale_test.class.php
Log:
We should also support %s, in additon to %1$s, %2$s, etc as many of our strings use %s instead of %1$s to specify positional parameters.
Modified: plog/trunk/class/locale/locale.class.php
===================================================================
--- plog/trunk/class/locale/locale.class.php 2007-08-01 20:07:00 UTC (rev 5767)
+++ plog/trunk/class/locale/locale.class.php 2007-08-01 20:39:07 UTC (rev 5768)
@@ -284,11 +284,17 @@
// the first parameter contains the id of the string
$str = $this->tr( $id );
- for( $i = 1; $i < func_num_args(); $i++ ) {
- $strId = "%{$i}\$s";
- $param = func_get_arg( $i ) ;
- $str = str_replace( $strId, $param, $str );
+ if( func_num_args() == 2 ) {
+ $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 );
+ }
+ }
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-01 20:07:00 UTC (rev 5767)
+++ plog/trunk/class/test/tests/locale/locale_test.class.php 2007-08-01 20:39:07 UTC (rev 5768)
@@ -29,9 +29,11 @@
$this->l->_loadLocaleFile();
$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->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" ));
}
/**
More information about the pLog-svn
mailing list