예제 #1
0
            fwrite($f, $new_file);
            fclose($f);
        }
        return true;
    }
    function usage()
    {
        $this->stderr('php i18n-comments.php COMMAND OUTPUTFILE INPUTFILES');
        $this->stderr('Extracts and replaces strings, which cannot be gettexted');
        $this->stderr('Commands:');
        $this->stderr('	extract POTFILE PHPFILES appends the strings to POTFILE');
        $this->stderr('	replace MOFILE PHPFILES replaces strings in PHPFILES with translations from MOFILE');
    }
    function cli()
    {
        global $argv, $commands;
        if (count($argv) < 4 || !in_array($argv[1], array_keys($this->commands))) {
            $this->usage();
            exit(1);
        }
        call_user_func_array(array(&$this, $this->commands[$argv[1]]), array_slice($argv, 2));
    }
}
// run the CLI only if the file
// wasn't included
$included_files = get_included_files();
if ($included_files[0] == __FILE__) {
    error_reporting(E_ALL);
    $not_gettexted = new NotGettexted();
    $not_gettexted->cli();
}