/** * @depends testTranslation */ public function testPhpArrayGenerator($translations) { //Export to a file $filename = __DIR__ . '/files/tmp-phparray.php'; $result = Gettext\Generators\PhpArray::toFile($translations, $filename); $this->assertTrue($result); $this->assertTrue(is_file($filename)); //Load the data as an array $array = (include $filename); $this->assertTrue(is_array($array)); $this->assertArrayHasKey('messages', $array); //Load the data as translations object $translations2 = Gettext\Extractors\PhpArray::fromFile($filename); //Compare the length of the translations in the array an in the translations (the array always has one more message) $this->assertEquals(count($array['messages']) - 1, count($translations2)); unlink($filename); }
$translation = $entries->find($context, $original, $plural); if ($translation) { $translation->setTranslation($original_translation); if ($plural) { $translation->setPlural($plural); if ($plural_translation) { $translation->setPluralTranslation($plural_translation, 0); } } } } if (!file_exists(dirname($file_with_translations))) { mkdir(dirname($file_with_translations), 0775, true); chmod(dirname($file_with_translations), 0775); } Gettext\Generators\PhpArray::generateFile($entries, $file_with_translations); if ($file_extension == 'js') { Gettext\Generators\Jed::generateFile($entries, 'locale/' . $lang . '/' . $file_to_translate); } ?> <div style="color: green">Saved Successfully</div><?php } ?> <!DOCTYPE html> <h1><?php echo $file_to_translate; ?> </h1> <h4><?php echo $lang; ?>