I18n CLI commands: replace --core parameter by Cli::core_mode()
This commit is contained in:
parent
f499087241
commit
c626bc177a
1 changed files with 12 additions and 17 deletions
29
src/I18n.php
29
src/I18n.php
|
@ -319,13 +319,12 @@ class I18n {
|
|||
* @return void
|
||||
*/
|
||||
public static function cli_extract_messages($command_args) {
|
||||
$core_mode = in_array('--core', $command_args);
|
||||
$root_path = $core_mode?self::$core_root_path:self::$root_path;
|
||||
$root_path = Cli::core_mode()?self::$core_root_path:self::$root_path;
|
||||
|
||||
// Store list of generated POT files
|
||||
$pot_files = array();
|
||||
|
||||
if ($core_mode) {
|
||||
if (Cli::core_mode()) {
|
||||
// List EesyPHP PHP files to parse
|
||||
$eesyphp_php_files = run_external_command(
|
||||
array(
|
||||
|
@ -401,8 +400,8 @@ class I18n {
|
|||
|
||||
// Extract messages from JS files using xgettext in each registered static directories
|
||||
foreach(Tpl::static_directories() as $idx => $static_directory) {
|
||||
if ($core_mode && $static_directory != Tpl::$core_static_directory) continue;
|
||||
if (!$core_mode && $static_directory == Tpl::$core_static_directory) continue;
|
||||
if (Cli::core_mode() && $static_directory != Tpl::$core_static_directory) continue;
|
||||
if (!Cli::core_mode() && $static_directory == Tpl::$core_static_directory) continue;
|
||||
// List JS files to parse
|
||||
$result = run_external_command(
|
||||
array('find', escapeshellarg(basename($static_directory)), '-name', "'*.js'"),
|
||||
|
@ -441,8 +440,8 @@ class I18n {
|
|||
|
||||
if (Tpl :: initialized()) {
|
||||
foreach (Tpl :: templates_directories() as $idx => $templates_directory) {
|
||||
if ($core_mode && $templates_directory != Tpl::$core_templates_directory) continue;
|
||||
if (!$core_mode && $templates_directory == Tpl::$core_templates_directory) continue;
|
||||
if (Cli::core_mode() && $templates_directory != Tpl::$core_templates_directory) continue;
|
||||
if (!Cli::core_mode() && $templates_directory == Tpl::$core_templates_directory) continue;
|
||||
// Extract messages from templates files using tsmarty2c.php
|
||||
$result = run_external_command(
|
||||
array(
|
||||
|
@ -502,20 +501,17 @@ class I18n {
|
|||
* @return bool
|
||||
*/
|
||||
public static function cli_update_messages($command_args) {
|
||||
$core_mode = false;
|
||||
$compendium_args = array();
|
||||
foreach ($command_args as $arg) {
|
||||
if ($arg == '--core')
|
||||
$core_mode = true;
|
||||
else if (!file_exists($arg))
|
||||
if (!file_exists($arg))
|
||||
Log :: fatal(self::_("Compendium file %s not found."), $arg);
|
||||
else {
|
||||
$compendium_args[] = '-C';
|
||||
$compendium_args[] = $arg;
|
||||
}
|
||||
}
|
||||
$domain = $core_mode?self::CORE_TEXT_DOMAIN:self::TEXT_DOMAIN;
|
||||
$root_path = $core_mode?self::$core_root_path:self::$root_path;
|
||||
$domain = Cli::core_mode()?self::CORE_TEXT_DOMAIN:self::TEXT_DOMAIN;
|
||||
$root_path = Cli::core_mode()?self::$core_root_path:self::$root_path;
|
||||
|
||||
$pot_file = "$root_path/messages.pot";
|
||||
if (!is_file($pot_file))
|
||||
|
@ -595,9 +591,8 @@ class I18n {
|
|||
* @return bool
|
||||
*/
|
||||
public static function cli_compile_messages($command_args) {
|
||||
$core_mode = in_array('--core', $command_args);
|
||||
$domain = $core_mode?self::CORE_TEXT_DOMAIN:self::TEXT_DOMAIN;
|
||||
$root_path = $core_mode?self::$core_root_path:self::$root_path;
|
||||
$domain = Cli::core_mode()?self::CORE_TEXT_DOMAIN:self::TEXT_DOMAIN;
|
||||
$root_path = Cli::core_mode()?self::$core_root_path:self::$root_path;
|
||||
if ($dh = opendir($root_path)) {
|
||||
$error = False;
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
|
@ -676,7 +671,7 @@ class I18n {
|
|||
}
|
||||
|
||||
// Compile messages from PO file to JS catalog file
|
||||
$js_catalog = self :: po2json($lang, $po_file, $core_mode);
|
||||
$js_catalog = self :: po2json($lang, $po_file, Cli::core_mode());
|
||||
$js_file = "$root_path/$lang.js";
|
||||
if(!$fd = fopen($js_file, 'w')) {
|
||||
Log :: error(self::_("Fail to open %s JS catalog file in write mode (%s)."),
|
||||
|
|
Loading…
Reference in a new issue