$build_mode = POTX_BUILD_MULTIPLE; break; case '--mode=single': $build_mode = POTX_BUILD_SINGLE; break; case '--debug': $files = array(__FILE__); break; case '--auto': $files = _potx_explore_dir('', '*', POTX_API_CURRENT, TRUE); break; } } // Fall back to --auto, if --files are not specified if (empty($files)) { $files = _potx_explore_dir('', '*', POTX_API_CURRENT, TRUE); } foreach ($files as $file) { potx_status('status', "Processing {$file}...\n"); _potx_process_file($file); } _potx_build_files(POTX_STRING_RUNTIME, $build_mode); _potx_build_files(POTX_STRING_INSTALLER, POTX_BUILD_SINGLE, 'installer'); _potx_write_files(); potx_status('status', "\nDone.\n"); return; // These are never executed, you can run potx-cli.php on itself to test it // ----------------------------------------------------------------------------- $a = t("Double quoted test string"); $b = t("Test string with %variable", array('%variable' => t('variable replacement'))); $c = t('Single qouted test string');
/** * Collect a list of file names relevant for extraction, * starting from the given path. * * @param $path * Where to start searching for files recursively. * Provide non-empty path values with a trailing slash. * @param $basename * Allows the restriction of search to a specific basename * (ie. to collect files for a specific module). * @param $api_version * Drupal API version to work with. * @todo * Add folder exceptions for other version control systems. */ function _potx_explore_dir($path = '', $basename = '*', $api_version = POTX_API_6) { // It would be so nice to just use GLOB_BRACE, but it is not available on all // operarting systems, so we are working around the missing functionality. $extensions = array('php', 'inc', 'module', 'engine', 'theme', 'install', 'info', 'profile'); if ($api_version > POTX_API_5) { $extensions[] = 'js'; } $files = array(); foreach ($extensions as $extension) { $files_here = glob($path . $basename . '.' . $extension); if (is_array($files_here)) { $files = array_merge($files, $files_here); } if ($basename != '*') { // Basename was specific, so look for things like basename.admin.inc as well. // If the basnename was *, the above glob() already covered this case. $files_here = glob($path . $basename . '.*.' . $extension); if (is_array($files_here)) { $files = array_merge($files, $files_here); } } } // Grab subdirectories. $dirs = glob($path . '*', GLOB_ONLYDIR); if (is_array($dirs)) { foreach ($dirs as $dir) { if (!preg_match("!(^|.+/)(CVS|.svn|.git)\$!", $dir)) { $files = array_merge($files, _potx_explore_dir("{$dir}/", $basename)); } } } // Skip our own files, because we don't want to get strings from them // to appear in the output, especially with the command line interface. // TODO: fix this to be able to autogenerate templates for potx itself. foreach ($files as $id => $file_name) { if (preg_match('!(potx-cli.php|potx.php)$!', $file_name)) { unset($files[$id]); } } return $files; }
$build_mode = POTX_BUILD_MULTIPLE; break; case '--mode=single': $build_mode = POTX_BUILD_SINGLE; break; case '--debug': $files = array(__FILE__); break; case '--auto': $files = _potx_explore_dir(); break; } } // Fall back to --auto, if --files are not specified if (empty($files)) { $files = _potx_explore_dir(); } foreach ($files as $file) { potx_status('status', "Processing {$file}...\n"); _potx_process_file($file); } _potx_build_files(POTX_STRING_RUNTIME, $build_mode); _potx_build_files(POTX_STRING_INSTALLER, POTX_BUILD_SINGLE, 'installer'); _potx_write_files(); potx_status('status', "\nDone.\n"); return; // These are never executed, you can run potx-cli.php on itself to test it // ----------------------------------------------------------------------------- $a = t("Double quoted test string"); $b = t("Test string with %variable", array('%variable' => t('variable replacement'))); $c = t('Single qouted test string');