]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - scripts/update_translations.php
Merge branch 'master' of ssh://zach@dev.controlyourself.ca/var/www/trunk
[quix0rs-gnu-social.git] / scripts / update_translations.php
1 <?php
2
3 set_time_limit(60);
4 chdir(dirname(__FILE__) . '/..');
5
6 /* Languages to pull */
7 $languages = array(
8         'da_DK' => 'http://laconi.ca/translate/download.php?file_id=93',
9         'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=97',
10         'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=87',
11         'eo'    => 'http://laconi.ca/translate/download.php?file_id=88',
12         'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=99',
13         'de_DE' => 'http://laconi.ca/translate/download.php?file_id=100',
14         'it_IT' => 'http://laconi.ca/translate/download.php?file_id=101',
15         'ko'    => 'http://laconi.ca/translate/download.php?file_id=102',
16         'no_NB' => 'http://laconi.ca/translate/download.php?file_id=104',
17         'pt'    => 'http://laconi.ca/translate/download.php?file_id=106',
18         'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=107',
19         'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=109',
20         'es'    => 'http://laconi.ca/translate/download.php?file_id=110',
21         'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=114',
22         'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=115',
23         'he_IL' => 'http://laconi.ca/translate/download.php?file_id=116',
24         'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=103',
25         'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=117',
26         'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=96',
27         'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=95',
28         'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=105',
29         'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=128'
30 );
31
32 /* Update the languages */
33 foreach ($languages as $code => $file) {
34
35         $lcdir='locale/'.$code;
36         $msgdir=$lcdir.'/LC_MESSAGES';
37         $pofile=$msgdir.'/laconica.po';
38         $mofile=$msgdir.'/laconica.mo';
39
40         /* Check for an existing */
41         if (!is_dir($msgdir)) {
42                 mkdir($lcdir);
43                 mkdir($msgdir);
44                 $existingSHA1 = '';
45         } else {
46                 $existingSHA1 = file_exists($pofile) ? sha1_file($pofile) : '';
47         }
48
49         /* Get the remote one */
50         $newFile = file_get_contents($file);
51
52         // Update if the local .po file is different to the one downloaded, or
53         // if the .mo file is not present.
54         if(sha1($newFile)!=$existingSHA1 || !file_exists($mofile)) {
55                 echo "Updating ".$code."\n";
56                 file_put_contents($pofile, $newFile);
57                 $prevdir = getcwd();
58                 chdir($msgdir);
59                 system('msgmerge -U laconica.po ../../laconica.pot');
60                 system('msgfmt -f -o laconica.mo laconica.po');
61                 chdir($prevdir);
62         } else {
63                 echo "Unchanged - ".$code."\n";
64         }
65 }
66 echo "Finished\n";