$strs) { $f[] = sprintf('# Generated by extract2lang.php on %s', date('c')); $f[] = sprintf('# Domain %s', $domain); $f[] = '# include translation strings from:'; $files = array_unique($files); foreach ($files as $source) { $f[] = sprintf('# %s', $source); } foreach ($strs as $str => $info) { $str = str_replace(array("\'", "\""), array("'", '"'), $str); $f[] = ''; $f[] = sprintf('# %s', $info[0]); $f[] = ';' . $str; $f[] = $str; $f[] = ''; } $f = implode("\n", $f); $dest = sprintf('%s/langs/%s/%s.%s.lang', APP_ROOT, 'en', $domain, 'en'); $dir = dirname($dest); if (!is_dir($dir)) { echo "making $dir\n"; mkdir($dir, 0755, true); } echo sprintf("saved %d strings in %s\n", count($strs), $dest); if (FALSE === file_put_contents($dest, $f)) echo "Failed to write.\n"; } echo "Done. kthxbye.\n"; exit($error);