Fixing a small css issue in the user class.
[elgg.git] / units / gettext / langpack.php
blob3373242a7e1105994720763263968877af690a9c
1 <?php
3 /*
4 * Little script for converting a Rosetta tarball into
5 * a language package.
7 * Usage:
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',
17 'de',
18 'is',
19 'it',
20 'es',
21 'sv',
22 'pt_BR',
23 'fr',
24 'lt',
25 'ko',
26 'eu',
27 'hu',
28 'en_GB');
30 $path = dirname(__FILE__).'/rosetta-elgg/';
31 $install_path = dirname(__FILE__).'/languages/';
33 // Extract the translations
34 $command = "tar xvzf rosetta-elgg.tar.gz";
35 shell_exec($command);
37 // Create archive
38 $command = "tar cvfj ".dirname(__FILE__)."/elgg-langpack_".date("mdY").".tar.bz2";
39 // shell_exec($command);
41 if (!file_exists($install_path))
43 mkdir($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))
60 mkdir($lang_path);
61 mkdir($lang_install_path);
64 print "Processing: ".$lang."\n";
65 $command = "msgfmt -o {$lang_install_path}elgg.mo {$path}{$file}";
66 shell_exec($command);
68 // Copy the .po file as well
69 copy($path.$file, $lang_install_path.$file);
71 if (in_array($lang, $complete))
73 // Create zip file
74 $command = "zip -r ".dirname(__FILE__).'/elgg-langpack_'.date("mdY").'.zip'." languages/{$lang}/*";
75 shell_exec($command);
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}/*";
82 else
84 $command = "tar --append --file=".dirname(__FILE__).'/elgg-langpack_'.date("mdY").'.tar'." languages/{$lang}/*";
86 shell_exec($command);
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";
97 shell_exec($command);