function read_nls_dir($root_dir, $plugin = true) { // get aloha core translation if ($plugin != true) { echo '################################# lib.aloha'; $dir = $root_dir . 'nls/'; // convert master $section = 'lib.aloha'; // master $language = 'en'; $data = file_get_contents($dir . 'i18n.js'); convert_nls_file($section, $language, $data); // convert other languages $languages = get_directories($dir); foreach ($languages as $language) { $path = $dir . $language . '/i18n.js'; if (is_file($path)) { $data = file_get_contents($path); convert_nls_file($section, $language, $data); } else { echo "[notice] file {$path} not found\n"; } } } else { echo "\n read root {$root_dir} \n"; $plugins = get_directories($root_dir); print_r($plugins); //$section = str_replace('/', '.', $root_dir); $section = str_replace(array('/', 'src.'), array('.', ''), $root_dir); $section = preg_replace("/[\\.]{2,}/", ".", $section); //$section = preg_replace(array("/[\.]{2,}/", ".src."), array(".", ""), $section); if (preg_match('/^\\.(.*)/', $section)) { $section = substr($section, 1); } if (preg_match('/(.*)\\.$/', $section)) { $section = substr($section, 0, -1); } $section_tpl = $section; foreach ($plugins as $plugin) { $section = $section_tpl . '.' . $plugin; echo "\n section {$section} \n"; // master $language = 'en'; $dir = $root_dir . $plugin . '/nls/'; $path = $dir . 'i18n.js'; echo "\n read nls {$path} \n"; echo 'check for file... '; if (is_file($path)) { echo 'is file... '; $data = file_get_contents($path); echo 'got contents... '; if (!empty($data)) { // do we need this? echo 'convert nls file... '; convert_nls_file($section, $language, $data, $plugin); } else { print_r($data); } echo 'done... '; } else { echo "[notice] file {$path} not found\n"; } // convert other languages $plugin_path = $root_dir . $plugin . '/nls/'; $languages = get_directories($plugin_path); //print_r($languages); foreach ($languages as $language) { $path = $dir . $language . '/i18n.js'; echo "\n read nls sub {$path} \n"; if (is_file($path)) { $data = file_get_contents($path); convert_nls_file($section, $language, $data, $plugin); } else { echo "[notice] file {$path} not found\n"; } } } } }
* in all php files in downloaded_php/downloads * * TODO: This isn't working properly. Probably need to escape more characters passed to r-option. This is probably best done in * the replace_include_constants plugin, however. */ include "test/framework/lib/header.php"; function eh($errno, $errstr) { if ($errno == E_NOTICE) { return; } print "{$errno}, {$errstr}"; } set_error_handler("eh", E_ALL); $directory_name = "downloaded_php/downloads/"; $dirs = get_directories($directory_name); foreach ($dirs as $dir) { $defines = ""; $i = 0; $files = get_all_files($dir); foreach ($files as $file) { if ($file != NULL) { $defines = $defines . get_defines($file); echo "Analysing {$file}\n"; } } foreach ($files as $file) { echo "Applying changes to {$file}\n"; apply_changes($file, $defines); } }
$exportZipFileData = file_get_contents($exportUrl); file_put_contents($exportZipFile, $exportZipFileData); // unzip the downloaded zip archive $zip = new ZipArchive(); $res = $zip->open($exportZipFile); if ($res === TRUE) { $command = "rm -r {$exportDir}*"; system($command); $zip->extractTo($exportDir); $zip->close(); echo "\n[ok] Translations downloaded and extracted\n"; } else { echo "\n[error] Translations not downloaded or extracted\n"; } // process all downloaded php language files and convert it to the aloha i8ln format $languages = get_directories($exportDir); $translations = array(); //print_r($languages); foreach ($languages as $language) { echo "\nread files for language: {$language}\n"; $sections = get_files($exportDir . $language . '/', ''); //print_r($sections); foreach ($sections as $section) { echo "read section: {$section}\n"; $lang = array(); require_once $exportDir . $language . '/' . $section; //print_r($lang); foreach ($lang as $i8ln_key => $i8ln_value) { $section = str_replace('.php', '', $section); //$translations[$language][$section][$i8ln_key] = $i8ln_value; $translations[$section][$language][$i8ln_key] = $i8ln_value;