/** * @param array $action */ function generateJson( $action ) { $jsPath = "extension/{$action['identifier']}/design/oscar/javascript/"; if ( is_dir( $jsPath ) ) { $convert = new ConvertTsToJSON( $jsPath . "com.lang.js", null, $action['param'] ); $convert->process(); eZCache::clearByID( array('ezjscore-packer'), 'template-block' ); } }
) ); $script->startup(); $options = $script->getOptions( '[ts:][js:][locale:]', "", array( 'ts' => 'path of the ts file', 'js' => 'path of the js file', 'locale' => 'locale of translation_value table' ) ); $script->initialize(); $jsPath = $options['js']; $tsPath = $options['ts']; $locale = $options['locale']; // information controls if(!$jsPath) $script->shutdown( 1 , 'JS path is mandatory' ); if($tsPath && !file_exists($tsPath)) $script->shutdown( 1 , 'Wrong path for the ts file' ); if(!$tsPath && !$locale) $script->shutdown( 1 , 'If the import is from DB, you must define a locale' ); // run conversion $convert = new ConvertTsToJSON($jsPath, $tsPath, $locale); $convert->process(); $script->shutdown();
foreach($clusters as $cluster) { $cli->output("Generating translations for cluster {$cluster}"); $iniFile = "extension/{$cluster}/settings/site.ini"; $ini = eZINI::fetchFromFile($iniFile); $locale = $ini->variable( 'RegionalSettings', 'Locale' ); if ( !$locale ) { $cli->output("No locale value in site.ini for cluster {$cluster}"); continue; } $jsOutputPath = "extension/{$cluster}/design/oscar/javascript/com.lang.js"; $converter = new ConvertTsToJSON($jsOutputPath, null, $locale); $converter->process(); } $script->shutdown(); function parseOptions(array $options) { $parsedOptions = array(); $existingClusters = ClusterTool::globCluster(); if (empty($options['clusterIdentifier'])) { $parsedOptions['clusters'] = $existingClusters; } else { $clusterList = explode(',', $options['clusterIdentifier']); $clusterList = array_intersect($clusterList, $existingClusters);