[5156] | 1 | #!/usr/bin/php -qn |
---|
| 2 | <?php |
---|
| 3 | if (isset($_SERVER['argc']) && $_SERVER['argc']<=1) |
---|
| 4 | { |
---|
| 5 | help(); |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | $language = trim($_SERVER['argv'][1]); |
---|
| 9 | if (!is_dir("language/$language")) |
---|
| 10 | { |
---|
| 11 | help(); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | $Files = array('common', 'admin', 'install', 'upgrade'); |
---|
| 15 | $exclude_keys = array('user_status_admin', 'user_status_generic', |
---|
| 16 | 'user_status_guest', 'user_status_normal', |
---|
| 17 | 'user_status_webmaster', 'Level 0', |
---|
| 18 | 'Level 1', 'Level 2', 'Level 4', 'Level 8', |
---|
| 19 | 'chronology_monthly_calendar', 'chronology_monthly_list', |
---|
| 20 | 'chronology_weekly_list'); |
---|
| 21 | |
---|
| 22 | foreach ($Files as $file) |
---|
| 23 | { |
---|
| 24 | $lang_file = sprintf('language/%s/%s.lang.php', $language, $file); |
---|
| 25 | $en_file = sprintf('language/en_UK/%s.lang.php', $file); |
---|
| 26 | include $lang_file; |
---|
| 27 | $source_lang = $lang; |
---|
| 28 | unset($lang); |
---|
| 29 | include $en_file; |
---|
| 30 | |
---|
| 31 | try |
---|
| 32 | { |
---|
| 33 | $fh = fopen($lang_file, 'w+'); |
---|
| 34 | |
---|
| 35 | fwrite($fh, copyright()); |
---|
| 36 | |
---|
| 37 | if ($file == 'common') |
---|
| 38 | { |
---|
| 39 | foreach ($lang_info as $key => $value) |
---|
| 40 | { |
---|
| 41 | fwrite($fh, sprintf("\$lang_info['%s'] = \"%s\";\n", |
---|
| 42 | $key, |
---|
| 43 | $value |
---|
| 44 | ) |
---|
| 45 | ); |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | fwrite($fh, "\n\n"); |
---|
| 49 | |
---|
| 50 | foreach ($lang as $key => $value) |
---|
| 51 | { |
---|
| 52 | if (is_array($value)) |
---|
| 53 | { |
---|
| 54 | foreach ($value as $k => $v) |
---|
| 55 | { |
---|
| 56 | fwrite($fh, sprintf("\$lang['%s'][%s] = \"%s\";\n", |
---|
| 57 | str_replace("'", "\'", trim($key)), |
---|
| 58 | trim($k), |
---|
| 59 | str_replace('"', '\"', trim($source_lang[$key][$k])) |
---|
| 60 | ) |
---|
| 61 | ); |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | elseif (in_array($key, $exclude_keys)) |
---|
| 65 | { |
---|
| 66 | fwrite($fh, sprintf("\$lang['%s'] = \"%s\";\n", |
---|
| 67 | str_replace("'", "\'", trim($key)), |
---|
| 68 | str_replace('"', '\"', trim($source_lang[$key])) |
---|
| 69 | ) |
---|
| 70 | ); |
---|
| 71 | } |
---|
| 72 | else |
---|
| 73 | { |
---|
| 74 | fwrite($fh, sprintf("\$lang['%s'] = \"%s\";\n", |
---|
| 75 | str_replace("'", "\'", trim($value)), |
---|
| 76 | str_replace('"', '\"', trim($source_lang[$key])) |
---|
| 77 | ) |
---|
| 78 | ); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | fwrite($fh, '?>'); |
---|
| 82 | fclose($fh); |
---|
| 83 | } |
---|
| 84 | catch (Exception $e) |
---|
| 85 | { |
---|
| 86 | print $e->getMessage(); |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | function help() |
---|
| 91 | { |
---|
| 92 | echo "\n"; |
---|
| 93 | echo 'usage : ', basename($_SERVER['argv'][0]), " <LANGUAGE CODE>\n"; |
---|
| 94 | echo "\n"; |
---|
| 95 | exit(1); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | function copyright() |
---|
| 99 | { |
---|
| 100 | return |
---|
| 101 | '<?php |
---|
| 102 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 103 | // | Piwigo - a PHP based photo gallery | |
---|
[5156] | 104 | // +-----------------------------------------------------------------------+ |
---|
[19703] | 105 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
[5156] | 106 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 107 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 108 | // +-----------------------------------------------------------------------+ |
---|
| 109 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 110 | // | it under the terms of the GNU General Public License as published by | |
---|
| 111 | // | the Free Software Foundation | |
---|
| 112 | // | | |
---|
| 113 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 114 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 115 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 116 | // | General Public License for more details. | |
---|
| 117 | // | | |
---|
| 118 | // | You should have received a copy of the GNU General Public License | |
---|
| 119 | // | along with this program; if not, write to the Free Software | |
---|
| 120 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 121 | // | USA. | |
---|
| 122 | // +-----------------------------------------------------------------------+ |
---|
| 123 | |
---|
| 124 | '; |
---|
| 125 | } |
---|
| 126 | ?> |
---|