/** * Console application, which extracts or replaces strings for * translation, which cannot be gettexted * * @package wordpress-i18n * @subpackage tools */ // see: http://php.net/tokenizer if (!defined('T_ML_COMMENT')) { define('T_ML_COMMENT', T_COMMENT); } else { define('T_DOC_COMMENT', T_ML_COMMENT); } WordPressIncluder::get('wp-includes/pomo/po.php'); WordPressIncluder::get('wp-includes/pomo/mo.php'); class NotGettexted { var $enable_logging = false; var $STAGE_OUTSIDE = 0; var $STAGE_START_COMMENT = 1; var $STAGE_WHITESPACE_BEFORE = 2; var $STAGE_STRING = 3; var $STAGE_WHITESPACE_AFTER = 4; var $STAGE_END_COMMENT = 4; var $commands = array('extract' => 'command_extract', 'replace' => 'command_replace'); function logmsg() { $args = func_get_args(); if ($this->enable_logging) { error_log(implode(' ', $args));
<?php namespace WordPress\L18N; WordPressIncluder::get('wp-includes/pomo/entry.php'); WordPressIncluder::get('wp-includes/pomo/translations.php'); use Translations; use Translation_Entry; /** * Responsible for extracting translatable strings from PHP source files * in the form of Translations instances */ class StringExtractor { var $rules = array('__' => array('string'), '_e' => array('string'), '_n' => array('singular', 'plural')); var $comment_prefix = 'translators:'; function __construct($rules = array()) { $this->rules = $rules; } function extract_from_directory($dir, $excludes = array(), $includes = array(), $prefix = '') { $old_cwd = getcwd(); chdir($dir); $translations = new Translations(); $file_names = (array) scandir('.'); foreach ($file_names as $file_name) { if ('.' == $file_name || '..' == $file_name) { continue; } if (preg_match('/\\.php$/', $file_name) && $this->does_file_name_match($prefix . $file_name, $excludes, $includes)) {