1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | define('PHPWG_ROOT_PATH', '../'); |
---|
25 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
26 | include_once( PHPWG_ROOT_PATH.'tools/translation_validated.inc.php' ); |
---|
27 | $languages = array_keys(get_languages()); |
---|
28 | |
---|
29 | $page['ref_compare'] = 'en_UK'; |
---|
30 | $page['ref_default_values'] = 'en_UK'; |
---|
31 | |
---|
32 | $file_list = array('common', 'admin', 'install', 'upgrade'); |
---|
33 | |
---|
34 | $metalang = array(); |
---|
35 | |
---|
36 | // preload reference languages |
---|
37 | $metalang[ $page['ref_compare'] ] = load_metalang($page['ref_compare'], $file_list); |
---|
38 | $metalang[ $page['ref_default_values'] ] = load_metalang($page['ref_default_values'], $file_list); |
---|
39 | |
---|
40 | foreach ($languages as $language) |
---|
41 | { |
---|
42 | if (in_array($language, array($page['ref_compare'], $page['ref_default_values']))) |
---|
43 | { |
---|
44 | continue; |
---|
45 | } |
---|
46 | echo '<h2>'.$language.'</h2>'; |
---|
47 | $metalang[$language] = load_metalang($language, $file_list); |
---|
48 | |
---|
49 | foreach ($file_list as $file) |
---|
50 | { |
---|
51 | if (isset($metalang[ $language ][$file])) |
---|
52 | { |
---|
53 | $missing_keys = array_diff( |
---|
54 | array_keys($metalang[ $page['ref_compare'] ][$file]), |
---|
55 | array_keys($metalang[ $language ][$file]) |
---|
56 | ); |
---|
57 | |
---|
58 | $output_missing = ''; |
---|
59 | foreach ($missing_keys as $key) |
---|
60 | { |
---|
61 | $output_missing.= get_line_to_translate($file, $key); |
---|
62 | } |
---|
63 | |
---|
64 | // strings not "really" translated? |
---|
65 | $output_duplicated = ''; |
---|
66 | foreach (array_keys($metalang[$language][$file]) as $key) |
---|
67 | { |
---|
68 | $exceptions = array('Level 0'); |
---|
69 | if (in_array($key, $exceptions)) |
---|
70 | { |
---|
71 | continue; |
---|
72 | } |
---|
73 | |
---|
74 | if (isset($validated_keys[$language]) and in_array($key, $validated_keys[$language])) |
---|
75 | { |
---|
76 | continue; |
---|
77 | } |
---|
78 | |
---|
79 | $local_value = $metalang[$language][$file][$key]; |
---|
80 | $ref_value = $metalang[ $page['ref_default_values'] ][$file][$key]; |
---|
81 | if ($local_value == $ref_value) |
---|
82 | { |
---|
83 | $output_duplicated.= get_line_to_translate($file, $key); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | if ('' != $output_missing or '' != $output_duplicated) |
---|
88 | { |
---|
89 | $output = ''; |
---|
90 | if ('' != $output_missing) |
---|
91 | { |
---|
92 | $output.= "// missing translations\n".$output_missing; |
---|
93 | } |
---|
94 | if ('' != $output_duplicated) |
---|
95 | { |
---|
96 | $output.= "\n// untranslated yet\n".$output_duplicated; |
---|
97 | } |
---|
98 | echo '<h3>'.$file.'.lang.php</h3>'; |
---|
99 | echo '<textarea style="width:100%;height:150px;">'.$output.'</textarea>'; |
---|
100 | } |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | echo '<h3>'.$file.'.lang.php is missing</h3>'; |
---|
105 | } |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | function load_metalang($language, $file_list) |
---|
110 | { |
---|
111 | global $lang, $user; |
---|
112 | |
---|
113 | $metalang = array(); |
---|
114 | foreach ($file_list as $file) |
---|
115 | { |
---|
116 | $lang = array(); |
---|
117 | $user['language'] = $language; |
---|
118 | if (load_language($file.'.lang', '', array('language'=>$language, 'no_fallback'=>true))) |
---|
119 | { |
---|
120 | $metalang[$file] = $lang; |
---|
121 | } |
---|
122 | } |
---|
123 | return $metalang; |
---|
124 | } |
---|
125 | |
---|
126 | function get_line_to_translate($file, $key) |
---|
127 | { |
---|
128 | global $metalang, $page; |
---|
129 | |
---|
130 | $print_key = str_replace("'", '\\\'', $key); |
---|
131 | $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]); |
---|
132 | return '$'."lang['".$print_key."'] = '".$print_value."';\n"; |
---|
133 | } |
---|
134 | ?> |
---|