]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - scripts/update_translations.php
Add a section to show popular groups (by posts)
[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=23',
9     'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=39',
10     'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=15',
11     'eo'    => 'http://laconi.ca/translate/download.php?file_id=10',
12     'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=19',
13     'de_DE' => 'http://laconi.ca/translate/download.php?file_id=18',
14     'it_IT' => 'http://laconi.ca/translate/download.php?file_id=21',
15     'ko'    => 'http://laconi.ca/translate/download.php?file_id=33',
16     'no_NB' => 'http://laconi.ca/translate/download.php?file_id=31',
17     'pt'    => 'http://laconi.ca/translate/download.php?file_id=8',
18     'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=72',
19     'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=26',
20     'es'    => 'http://laconi.ca/translate/download.php?file_id=9',
21     'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=37',
22     'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=44',
23     'he_IL' => 'http://laconi.ca/translate/download.php?file_id=71',
24     'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=67',
25     'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=43',
26     'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=63',
27     'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=49',
28     'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=51',
29     'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=55'
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";