$v) { echo sprintf("> %s has %d translated strings, adding the rest %d untranslated.", $k, count($v), ($number_of_eng_strings - count($v))); $v = array_merge($eng_array, $v); // add untranslated strings $f = array(); $f[] = sprintf('# Generated by pa2lang.php on %s', date('c')); $f[] = sprintf('# from %s $%s', $php_source, $var); foreach ($v as $s0 => $s1) { $s0 = str_replace("\n", ' ', $s0); $s0 = preg_replace('/\s+/', ' ', $s0); // remove multiple spaces $s0 = str_replace("\'", "'", $s0); // remove also backslashes if (is_array($s1)) { echo "\nWe have an array for string $k:'$s0':\n"; foreach ($s1 as $sv) echo " * ", $sv, "\n"; echo "\nThis can't be inserted into this .lang file. Fix this upstream and come back.\n\n"; exit(1); } $s1 = str_replace("\n", ' ', $s1); $s1 = preg_replace('/\s+/', ' ', $s1); $s1 = str_replace("\'", "'", $s1); $f[] = ''; $f[] = ';' . $s0; $f[] = $s1; $f[] = "\n"; } echo " ok\n"; $files[$k] = implode("\n", $f); } echo "Saving those into ...\n"; foreach ($files as $k => $data) { $file = str_replace('{LOC}', $k, $dest); // file_put_contents($file, $data); } echo "Done.\n"; exit(0);