Browse Source

Minor code improvements

Florian Krämer 8 years ago
parent
commit
0620c529d0
2 changed files with 11 additions and 12 deletions
  1. 4 5
      src/I18n/Parser/PoFileParser.php
  2. 7 7
      tests/TestCase/I18n/Parser/PoFileParserTest.php

+ 4 - 5
src/I18n/Parser/PoFileParser.php

@@ -14,6 +14,8 @@
  */
 namespace Cake\I18n\Parser;
 
+use Cake\I18n\Translator;
+
 /**
  * Parses file in PO format
  *
@@ -23,9 +25,6 @@ namespace Cake\I18n\Parser;
  */
 class PoFileParser
 {
-
-    const PLURAL_PREFIX = 'p:';
-
     /**
      * Parses portable object (PO) format.
      *
@@ -168,9 +167,9 @@ class PoFileParser
             $key = stripcslashes($item['ids']['plural']);
 
             if ($context !== null) {
-                $messages[static::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
+                $messages[Translator::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
             } else {
-                $messages[static::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
+                $messages[Translator::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
             }
         }
     }

+ 7 - 7
tests/TestCase/I18n/Parser/PoFileParserTest.php

@@ -77,8 +77,8 @@ class PoFileParserTest extends TestCase
             'p:%d = 0 or > 1' => [
                 '_context' => [
                     'Another Context' => [
-                        (int)0 => '%d = 1 (translated)',
-                        (int)1 => '%d = 0 or > 1 (translated)'
+                        0 => '%d = 1 (translated)',
+                        1 => '%d = 0 or > 1 (translated)'
                     ]
                 ]
             ],
@@ -90,11 +90,11 @@ class PoFileParserTest extends TestCase
             'p:%-5d = 0 or > 1' => [
                 '_context' => [
                     '' => [
-                        (int)0 => '%-5d = 1 (translated)',
-                        (int)1 => '',
-                        (int)2 => '',
-                        (int)3 => '',
-                        (int)4 => '%-5d = 0 or > 1 (translated)'
+                        0 => '%-5d = 1 (translated)',
+                        1 => '',
+                        2 => '',
+                        3 => '',
+                        4 => '%-5d = 0 or > 1 (translated)'
                     ]
                 ]
             ]