Skip to content

Commit

Permalink
don't strip newlines (it makes debugging difficultr). work with my wi…
Browse files Browse the repository at this point in the history
…ndows version of php (wtf no argv?). die if you can't find the templates folder (since cygwin is being dumb today). print progress as you go

git-svn-id: file:///root/var/svn/trunk/uploadr@368 2ccee060-bf41-0410-b5a3-d28fdbd3ea41
  • Loading branch information
iamcal committed Apr 28, 2008
1 parent 2ea9a43 commit a807d34
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions strings_import.php
Expand Up @@ -4,6 +4,12 @@

$locale = dirname(__FILE__) . '/MacUploadr.app/Contents/Resources/chrome/locale';

if (count($_GET)){
$argv = array_keys($_GET);
array_unshift($argv, 'foo.php');
}


# Gotta have a source folder for all those other languages
if (!isset($argv[1])) {
die("Usage: $argv[0] <intl-directory>\n");
Expand All @@ -12,6 +18,7 @@
# Clean each directory's files
foreach (array('de-de', 'es-us', 'fr-fr', 'it-it', 'ko-kr', 'pt-br', 'zh-hk') as $l) {
$dir = opendir("$argv[1]/$l");
if (!$dir) die;
while (false !== $file = readdir($dir)) {

# Only act on DTD and PROPERTIES files
Expand All @@ -31,7 +38,7 @@
echo "[error] Reading $file\n";
continue;
}
$text = trim(str_replace("\n\n", "\n", preg_replace('/^<\?php.*\?>$/ms', '', $text)));
$text = trim(preg_replace('/^<\?php.*\?>$/ms', '', $text));

# Process each string
$lines = explode("\n", $text);
Expand Down Expand Up @@ -73,14 +80,14 @@
echo "[error] Opening $file\n";
continue;
}
if (false === fwrite($file_p, implode("\n",
array_diff($lines, array(''))))) {
if (false === fwrite($file_p, implode("\n", $lines))) {
echo "[error] Writing $file\n";
}
if (false === fclose($file_p)) {
echo "[error] Closing $file\n";
}

echo "[ok] finished writing $l/$file\n";
}
closedir($dir);
}
Expand Down

0 comments on commit a807d34

Please sign in to comment.