4 * Little script for converting a Rosetta tarball into
8 * download a rosetta export from
9 * https://launchpad.net/elgg/trunk/+pots/elgg/+export
10 * and run this script at the download location
12 * Notice: this script will only work on *NIX systems
15 // Feel free to add your own
16 $complete = array('nl',
30 $path = dirname(__FILE__
).'/rosetta-elgg/';
31 $install_path = dirname(__FILE__
).'/languages/';
33 // Extract the translations
34 $command = "tar xvzf rosetta-elgg.tar.gz";
38 $command = "tar cvfj ".dirname(__FILE__
)."/elgg-langpack_".date("mdY").".tar.bz2";
39 // shell_exec($command);
41 if (!file_exists($install_path))
46 $basedir = opendir($path);
48 while (false !== ($file = readdir($basedir)))
51 if (substr($file, -3, 3) == ".po")
53 $lang = substr($file, 0, -3);
55 $lang_path = $install_path.$lang.'/';
56 $lang_install_path = $lang_path.'LC_MESSAGES/';
58 if (!file_exists($lang_path))
61 mkdir($lang_install_path);
64 print "Processing: ".$lang."\n";
65 $command = "msgfmt -o {$lang_install_path}elgg.mo {$path}{$file}";
68 // Copy the .po file as well
69 copy($path.$file, $lang_install_path.$file);
71 if (in_array($lang, $complete))
74 $command = "zip -r ".dirname(__FILE__
).'/elgg-langpack_'.date("mdY").'.zip'." languages/{$lang}/*";
77 // Create UNIX archive
78 if (!file_exists(dirname(__FILE__
).'/elgg-langpack_'.date("mdY").'.tar'))
80 $command = "tar cvf ".dirname(__FILE__
).'/elgg-langpack_'.date("mdY").'.tar'." languages/{$lang}/*";
84 $command = "tar --append --file=".dirname(__FILE__
).'/elgg-langpack_'.date("mdY").'.tar'." languages/{$lang}/*";
91 if (file_exists(dirname(__FILE__
)."/elgg-langpack_".date("mdY").".tar.bz2"))
93 unlink(dirname(__FILE__
)."/elgg-langpack_".date("mdY").".tar.bz2");
96 $command = "bzip2 ".dirname(__FILE__
)."/elgg-langpack_".date("mdY").".tar";