コード例 #1
0
 public function testCreator()
 {
     //Extract translations
     $translations1 = Gettext\Extractors\PhpCode::fromFile(__DIR__ . '/files/phpCode-example.php');
     $translations2 = Gettext\Translations::fromPhpCodefile(__DIR__ . '/files/phpCode-example.php');
     $this->assertInstanceOf('Gettext\\Translations', $translations1);
     $this->assertInstanceOf('Gettext\\Translations', $translations2);
     $this->assertEquals($translations1, $translations2);
     $result = Gettext\Generators\Po::toString($translations1);
     $this->assertEquals($result, $translations2->toPoString());
 }
コード例 #2
0
ファイル: GettextTest.php プロジェクト: vipkailiai/FCVOVA
 public function testWordpress()
 {
     //Extract translations
     $translations = Gettext\Extractors\PhpCode::fromFile(__DIR__ . '/files/wordpress-template.php');
     $this->assertInstanceOf('Gettext\\Translations', $translations);
     $po = Gettext\Generators\Po::toString($translations);
     $assert = file_get_contents(__DIR__ . '/files/wordpress-template.po');
     //remove the first 13 lines with temp info
     $po = explode("\n", $po);
     $assert = explode("\n", $assert);
     $po = implode("\n", array_splice($po, 13));
     $assert = implode("\n", array_splice($assert, 13));
     $this->assertEquals($po, $assert);
 }
コード例 #3
0
ファイル: js2po.php プロジェクト: wildalmighty/gettext
function buildOptions($args)
{
    $options = array('-o' => null, '-i' => null);
    $len = count($args);
    $i = 0;
    while ($i < $len) {
        if (preg_match('#^-[a-z]$#i', $args[$i])) {
            $options[$args[$i]] = isset($args[$i + 1]) ? trim($args[$i + 1]) : true;
            $i += 2;
        } else {
            $options[] = $args[$i];
            $i++;
        }
    }
    return $options;
}
spl_autoload_register('autoload');
$options = buildOptions($argv);
$input = $options['-i'];
$output = $options['-o'];
//Custom functions
Gettext\Extractors\JsCode::$functions = array('T_' => '__');
if (!strpos($input, ':\\') && $input[0] !== DIRECTORY_SEPARATOR) {
    $input = __DIR__ . DIRECTORY_SEPARATOR . $input;
}
if (!strpos($output, ':\\') && $output[0] !== DIRECTORY_SEPARATOR) {
    $output = __DIR__ . DIRECTORY_SEPARATOR . $output;
}
$Entries = Gettext\Extractors\JsCode::extract($input);
Gettext\Generators\Po::generateFile($Entries, $output);