* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBNLS_Extractor'); /** * Native Lanauge Support: Extractor Config Files * * Extract translatable strings from XML config files. * * @version 0.1.0 * @package WB * @subpackage nls */ class WBNLS_Extractor_ConfigFile extends WBNLS_Extractor { /** * markup scanner * @var WBMarkup_Scanner */ private $scanner; /** * markup handler * @var WBMarkup_Handler_I18nExtractor */ private $handler; /** * config Loader * @var WBCoonfig_Loader_File */ protected $configLoader; /** * init actual config loader * * In this case load XML config from files * * @see WBConfig_Loader_File */ protected function startConfigLoader() { $this->configLoader = WBClass::create('WBConfig_Loader_File'); } /** * setup extractor * * Start scanner and handler * * @see WBMarkup_Handler_I18nExtractor_XmlConfig * @see WBMarkup_Scanner */ protected function onStart() { $this->scanner = WBClass::create('WBMarkup_Scanner'); $this->handler = WBClass::create('WBMarkup_Handler_I18nExtractor_XmlConfig'); $this->handler->setImporter($this->imp); $this->scanner->setHandler($this->handler); } /** * actually extract messages * * Extract messages from XML config files * * @return int $total */ protected function extract() { $this->startConfigLoader(); return $this->extractXmlConfigDir(''); } /** * extract messages from XML config * * Use config loader to list and fetch XML config (e.g. from file or database) * scan config and list recursively. * * @param string $dir * @return int */ private function extractXmlConfigDir($dir) { $d = $dir; if (!empty($d)) { $d .= '/'; } $data = ''; $exp = null; if ($this->configLoader->load($dir, $data, $exp, true)) { $this->scanner->scan($data); } $list = $this->configLoader->ls($dir); $cnt = count($list); foreach ($list as $l) { $cnt += $this->extractXmlConfigDir($d . $l); } return $cnt; } } ?>