/** * クラスファイルからgettext文字列を抜き出してpotファイルを作成する * @param string $path * @param string $lc_messages_path */ public static function po_generate($path, $lc_messages_path) { $messages = array(); foreach (File::ls($path, true) as $file) { if ($file->isClass()) { ob_start(); include_once $file->fullname(); Rhaco::import($file->oname()); ob_get_clean(); $ref = Info::reflection($file->oname()); foreach ($ref->methods as $method) { foreach ($method->gettext as $text) { $messages[$text->str]["#: " . str_replace($path, "", $file->fullname()) . ":" . $text->line] = true; } } } } ksort($messages, SORT_STRING); $output_src = sprintf(Text::plain(' # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE\'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\\n" "Report-Msgid-Bugs-To: \\n" "POT-Creation-Date: %s\\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" "Language-Team: LANGUAGE <*****@*****.**>\\n" '), date("Y-m-d H:iO")) . "\n\n"; foreach ($messages as $str => $lines) { $output_src .= "\n" . implode("\n", array_keys($lines)) . "\n"; $output_src .= "msgid \"" . $str . "\"\n"; $output_src .= "msgstr \"\"\n"; } File::write(File::absolute($lc_messages_path, "messages.pot"), $output_src); //Rhaco::import("ext.Setup"); //Setup::po_generate(dirname(__FILE__),Rhaco::selfpath()."/resources/locale/"); //Setup::mo_generate(Rhaco::selfpath()."/resources/locale/"); //Test::each_flush(); }
/** * テストを実行する * @param string $class クラス名 * @param strgin $method メソッド名 */ public static final function verify($class, $method = null, $block_name = null) { if (!class_exists($class) && Rhaco::import($class)) { $pos = strrpos($class, "."); $class = substr($class, $pos !== false ? $pos + 1 : $pos); } $ref = Info::reflection($class); self::$current_file = $ref->path; self::$current_class = $ref->name; foreach ($ref->methods as $name => $m) { self::$current_method = $name; if ($method === null || $method == $name) { self::execute($m, $block_name); } } self::$current_class = null; self::$current_file = null; self::$current_method = null; return new self(); }