|
|
@@ -433,6 +433,146 @@ class BasicsTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testTranslateWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslateWithFormatSpecifiers() {
|
|
|
+ $expected = 'Check, one, two, three';
|
|
|
+ $result = __('Check, %+10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, +1, two, three';
|
|
|
+ $result = __('Check, %+5d, two, three', 1);
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, @@one, two, three';
|
|
|
+ $result = __('Check, %\'@+10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, one, two , three';
|
|
|
+ $result = __('Check, %-10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, one, two##, three';
|
|
|
+ $result = __('Check, %\'#-10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, one, two, three';
|
|
|
+ $result = __d('default', 'Check, %+10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, @@one, two, three';
|
|
|
+ $result = __d('default', 'Check, %\'@+10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, one, two , three';
|
|
|
+ $result = __d('default', 'Check, %-10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $expected = 'Check, one, two##, three';
|
|
|
+ $result = __d('default', 'Check, %\'#-10s, three', 'one, two');
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testTranslateDomainPluralWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslateDomainPluralWithFormatSpecifiers() {
|
|
|
+ $result = __dn('core', '%+5d item.', '%+5d items.', 1, 1);
|
|
|
+ $expected = ' +1 item.';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dn('core', '%-5d item.', '%-5d items.', 10, 10);
|
|
|
+ $expected = '10 items.';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dn('core', '%\'#+5d item.', '%\'*+5d items.', 1, 1);
|
|
|
+ $expected = '###+1 item.';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dn('core', '%\'#+5d item.', '%\'*+5d items.', 90, 90);
|
|
|
+ $expected = '**+90 items.';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dn('core', '%\'#+5d item.', '%\'*+5d items.', 9000, 9000);
|
|
|
+ $expected = '+9000 items.';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test testTranslatePluralWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslatePluralWithFormatSpecifiers() {
|
|
|
+ Configure::write('Config.language', 'rule_1_po');
|
|
|
+
|
|
|
+ $result = __n('%-5d = 1', '%-5d = 0 or > 1', 10);
|
|
|
+ $expected = '%-5d = 0 or > 1 (translated)';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test testTranslateDomainCategoryWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslateDomainCategoryWithFormatSpecifiers() {
|
|
|
+ Configure::write('Config.language', 'rule_1_po');
|
|
|
+
|
|
|
+ $result = __dc('default', '%+10s world', 6, 'hello');
|
|
|
+ $expected = ' hello world';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dc('default', '%-10s world', 6, 'hello');
|
|
|
+ $expected = 'hello world';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dc('default', '%\'@-10s world', 6, 'hello');
|
|
|
+ $expected = 'hello@@@@@ world';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test testTranslateDomainCategoryPluralWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslateDomainCategoryPluralWithFormatSpecifiers() {
|
|
|
+ Configure::write('Config.language', 'rule_1_po');
|
|
|
+
|
|
|
+ $result = __dcn('default', '%-5d = 1', '%-5d = 0 or > 1', 0, 6);
|
|
|
+ $expected = '%-5d = 0 or > 1 (translated)';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __dcn('default', '%-5d = 1', '%-5d = 0 or > 1', 1, 6);
|
|
|
+ $expected = '%-5d = 1 (translated)';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test testTranslateCategoryWithFormatSpecifiers
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTranslateCategoryWithFormatSpecifiers() {
|
|
|
+ $result = __c('Some string with %+10s', 6, 'arguments');
|
|
|
+ $expected = 'Some string with arguments';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __c('Some string with %-10s: args', 6, 'arguments');
|
|
|
+ $expected = 'Some string with arguments : args';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $result = __c('Some string with %\'*-10s: args', 6, 'arguments');
|
|
|
+ $expected = 'Some string with arguments*: args';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* test __n()
|
|
|
*
|
|
|
* @return void
|