function ls_generic($dir, $args) { $defaults = array('project' => 'ls-core', 'output' => null, 'default_output' => 'limesurvey.pot', 'includes' => array(), 'excludes' => $this->excludes, 'extract_not_gettexted' => false, 'not_gettexted_files_filter' => false); $args = array_merge($defaults, $args); extract($args); $placeholders = array(); $placeholders['version'] = '2.0'; $output = is_null($output) ? $default_output : $output; $res = $this->xgettext($project, $dir, $output, $placeholders, $excludes, $includes); if (!$res) { return false; } if ($extract_not_gettexted) { $old_dir = getcwd(); $output = realpath($output); chdir($dir); $php_files = NotGettexted::list_php_files('.'); $php_files = array_filter($php_files, $not_gettexted_files_filter); $not_gettexted = new NotGettexted(); $res = $not_gettexted->command_extract($output, $php_files); chdir($old_dir); /* Adding non-gettexted strings can repeat some phrases */ $output_shell = escapeshellarg($output); system("msguniq --use-first {$output_shell} -o {$output_shell}"); } return $res; }
function wp_generic($dir, $args) { $defaults = array('project' => 'wp-core', 'output' => null, 'default_output' => 'wordpress.pot', 'includes' => array(), 'excludes' => array_merge(array('wp-admin/includes/continents-cities\\.php', 'wp-content/themes/twenty.*'), $this->ms_files), 'extract_not_gettexted' => false, 'not_gettexted_files_filter' => false); $args = array_merge($defaults, $args); extract($args); $placeholders = array(); if ($wp_version = $this->wp_version($dir)) { $placeholders['version'] = $wp_version; } else { return false; } $output = is_null($output) ? $default_output : $output; $res = $this->xgettext($project, $dir, $output, $placeholders, $excludes, $includes); if (!$res) { return false; } if ($extract_not_gettexted) { $old_dir = getcwd(); $output = realpath($output); chdir($dir); $php_files = NotGettexted::list_php_files('.'); $php_files = array_filter($php_files, $not_gettexted_files_filter); $not_gettexted = new NotGettexted(); $res = $not_gettexted->command_extract($output, $php_files); chdir($old_dir); /* Adding non-gettexted strings can repeat some phrases */ $output_shell = escapeshellarg($output); system("msguniq --use-first {$output_shell} -o {$output_shell}"); } return $res; }
function list_php_files($dir) { $files = array(); $items = scandir($dir); foreach ((array) $items as $item) { $full_item = $dir . '/' . $item; if ('.' == $item || '..' == $item) { continue; } if ('.php' == substr($item, -4)) { $files[] = $full_item; } if (is_dir($full_item)) { $files += array_merge($files, NotGettexted::list_php_files($full_item, $files)); } } return $files; }