]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - scripts/update_translations.php
translation updates
[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=11',
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=27',
23                                                    );
24
25 /* Update the languages */
26 foreach ($languages as $code => $file) {
27             /* Check for an existing */
28             if (!is_dir('locale/' . $code)) {
29                                 mkdir('locale/' . $code);
30                                 mkdir('locale/' . $code . '/LC_MESSAGES');
31                                 $existingSHA1 = '';
32                 } else {
33                         $existingSHA1 = file_exists('locale/' . $code . '/LC_MESSAGES/laconica.po') ? sha1_file('locale/' . $code . '/LC_MESSAGES/laconica.po') : '';
34                 }
35         
36             /* Get the remote one */
37             $newFile = file_get_contents($file);
38         
39             /* Are the different? */
40             if (sha1($newFile) != $existingSHA1) {
41                                 /* Yes, update */
42                                 file_put_contents('locale/' . $code . '/LC_MESSAGES/laconica.po', $newFile);
43                                 $prevdir = getcwd();
44                                 chdir('locale/' . $code . '/LC_MESSAGES/');
45                                 system('msgmerge -U laconica.po ../../laconica.pot');
46                                 system('msgfmt -f -o laconica.mo laconica.po');
47                                 chdir($prevdir);
48                 }
49 }
50