コード例 #1
0
 public function testEscapeKeysIfNecessary()
 {
     $this->writer->write($this->directory, 'escaped', array('EntryWith:Colon' => 'Value', 'Entry With Spaces' => 'Value'));
     $this->assertFileEquals(__DIR__ . '/Fixtures/escaped.txt', $this->directory . '/escaped.txt');
 }
コード例 #2
0
 private function generateTextFiles($targetDirectory, array $locales)
 {
     $displayLocales = array_unique(array_merge($this->languageBundle->getLocales(), $this->regionBundle->getLocales()));
     $txtWriter = new TextBundleWriter();
     // Generate a list of locale names in the language of each display locale
     // Each locale name has the form: "Language (Script, Region, Variant1, ...)
     // Script, Region and Variants are optional. If none of them is available,
     // the braces are not printed.
     foreach ($displayLocales as $displayLocale) {
         // Don't include ICU's root resource bundle
         if ('root' === $displayLocale) {
             continue;
         }
         $names = array();
         foreach ($locales as $locale) {
             // Don't include ICU's root resource bundle
             if ($locale === 'root') {
                 continue;
             }
             if (null !== ($name = $this->generateLocaleName($locale, $displayLocale))) {
                 $names[$locale] = $name;
             }
         }
         // If no names could be generated for the current locale, skip it
         if (0 === count($names)) {
             continue;
         }
         $txtWriter->write($targetDirectory, $displayLocale, array('Locales' => $names));
     }
 }
コード例 #3
0
 public function testWrite()
 {
     $this->writer->write($this->directory, 'en', array('Entry1' => array('Array' => array('foo', 'bar', array('Key' => 'value')), 'Integer' => 5, 'IntVector' => array(0, 1, 2, 3), 'FalseBoolean' => false, 'TrueBoolean' => true, 'Null' => null, 'Float' => 1.23), 'Entry2' => 'String'));
     $this->assertFileEquals(__DIR__ . '/Fixtures/en.txt', $this->directory . '/en.txt');
 }