15 |
16 |
57 |
58 |
59 |
60 | append(new RecursiveIteratorIterator($directory));
105 | }
106 |
107 | function diff_versions($leftContent, $rightContent)
108 | {
109 | $rightVersion = null;
110 |
111 | $pattern = '/^(?!FONT|\\s*\\*|\\#include|\\s*ICON)[^"\\n]*"\\K(?!\\s*(?:"|\\n))([^"]+)/m';
112 |
113 | if (preg_match_all($pattern, $leftContent, $matches) <= 0) {
114 | throw new Exception('Left content has no version line.');
115 | }
116 |
117 | $leftVersion = $matches[1];
118 |
119 | if (preg_match_all($pattern, $rightContent, $matches) <= 0) {
120 | throw new Exception('Right content has no version line.');
121 | }
122 |
123 | $rightVersion = $matches[1];
124 |
125 | return [
126 | 'diff' => array_intersect($leftVersion, $rightVersion),
127 | 'leftVersion' => $leftVersion,
128 | 'rightVersion' => $rightVersion,
129 | ];
130 | }
131 |
132 | function exceptions_error_handler($severity, $message, $filename, $lineno)
133 | {
134 | if (error_reporting() == 0) {
135 | return;
136 | }
137 | if (error_reporting() & $severity) {
138 | throw new ErrorException($message, 0, $severity, $filename, $lineno);
139 | }
140 | }
141 |
142 | set_error_handler('exceptions_error_handler');
143 |
144 | $regex = new RegexIterator($it, '/^.+'.$langDir.'.+('.$originLang.')\.'.$fileExt.'$/i', RecursiveRegexIterator::GET_MATCH);
145 |
146 | $missing = $allStrings = 0;
147 |
148 | $lang = htmlspecialchars($_GET['lang']);
149 | // Search for eg. PL,Pl,pl
150 | $fileSearch = strtoupper($lang).','.ucfirst($lang).','.strtolower($lang);
151 |
152 | // ReactOS and Wine Strings - array
153 | $ignoredROSStrings = file($ROSSpellFilename, FILE_IGNORE_NEW_LINES);
154 | $ignoredWineStrings = file($wineSpellFilename, FILE_IGNORE_NEW_LINES);
155 |
156 | $regex->rewind();
157 | while ($regex->valid()) {
158 | if (!$regex->isDot()) {
159 | $file = glob($regex->getPathInfo().'/*{'.$fileSearch.'}*.'.$fileExt, GLOB_BRACE);
160 |
161 | $isFile = array_filter($file);
162 |
163 | if (empty($isFile)) {
164 | echo '
No translation for path '.$regex->getPathInfo().'
';
165 | } else {
166 | $fileContent1 = file_get_contents($regex->key());
167 | $fileContent2 = file_get_contents($file[0]);
168 |
169 | $array = diff_versions($fileContent1, $fileContent2);
170 |
171 | if ($array['diff']) {
172 | $currentMissing = $missing;
173 | $missingTextMessage = null;
174 |
175 | foreach ($array['leftVersion'] as $index => $english) {
176 | // Catch offset error
177 | try {
178 | // Check if this same and ignore some words
179 | if ($english === $array['rightVersion'][$index] && !in_array($english, $ignoredROSStrings) && !in_array($english, $ignoredWineStrings)) {
180 | $missingTextMessage .= '
Missing translation: '.htmlspecialchars($english).'
';
181 | $missing++;
182 | }
183 | $allStrings++;
184 | } catch (Exception $e) {
185 | $missingTextMessage .= 'Missing stuff in your language
';
186 | $allStrings++;
187 | $missing++;
188 | }
189 | }
190 |
191 | if ($currentMissing == $missing) {
192 | $messageForFile = 'Seems
OK :) Some strings was ignored by ReactOS and Wine spell files.
';
193 | } elseif ($detailsTag) {
194 | $messageForFile = '
Click here to see/hide missing translations in file ('.($missing - $currentMissing).')
'.$missingTextMessage.'';
195 | } else {
196 | $messageForFile = $missingTextMessage;
197 | }
198 |
199 | if ($currentMissing != $missing || $showTranslationOK) {
200 | $pathFromRoot = str_replace($ROSDir, '', $regex->getPathInfo());
201 | echo $regex->getPathInfo().' (
Go to GitHub)
'.$messageForFile.'
';
202 | }
203 | }
204 | }
205 | }
206 | $regex->next();
207 | }
208 |
209 | $languppercase = strtoupper($lang);
210 |
211 | echo "
All strings for english: $allStrings
";
212 | echo "
Missing translations for your language ($languppercase): $missing
";
213 |
214 | // Rounded percent
215 | $percent = round((($allStrings - $missing) / $allStrings) * 100, 2);
216 | echo "
Language $languppercase translated in $percent%
";
217 | }
218 |
219 | include_once 'footer.php';
220 |
--------------------------------------------------------------------------------
/encoding.php:
--------------------------------------------------------------------------------
1 |
5 | * AUTHOR URL: http://it-maniak.pl/
6 | */
7 |
8 | include_once 'header.php';
9 | include_once 'langcodes.php';
10 | ?>
11 |
12 |
Search for wrong encoded files
13 |
14 |
15 |
16 |
57 |
58 |
59 |
60 | append(new RecursiveIteratorIterator($directory));
105 | }
106 |
107 | $regex = new RegexIterator($it, '/^.+'.$langDir.'.+('.$originLang.')\.'.$fileExt.'$/i', RecursiveRegexIterator::GET_MATCH);
108 |
109 | $allWrongEnc = 0;
110 |
111 | $lang = htmlspecialchars($_GET['lang']);
112 | // Search for eg. PL,Pl,pl
113 | $fileSearch = strtoupper($lang).','.ucfirst($lang).','.strtolower($lang);
114 |
115 | // UTF-8 BOM starts with EF BB BF
116 | define('UTF8_BOM', chr(0xEF).chr(0xBB).chr(0xBF));
117 |
118 | $regex->rewind();
119 | while ($regex->valid()) {
120 | if (!$regex->isDot()) {
121 | $file = glob($regex->getPathInfo().'/*{'.$fileSearch.'}*.'.$fileExt, GLOB_BRACE);
122 |
123 | $isFile = array_filter($file);
124 |
125 | if (!empty($isFile)) {
126 | $text = file_get_contents($file[0]);
127 | // UTF-8 is good
128 | if (mb_check_encoding($text, 'UTF-8')) {
129 | $first3 = substr($text, 0, 3);
130 | // But UTF-8 with BOM not!
131 | if ($first3 === UTF8_BOM) {
132 | echo 'Detected
UTF-8 BOM in '.$file[0].'
';
133 | $allWrongEnc++;
134 | }
135 | } else {
136 | // Other encoding
137 | echo 'Detected
other encoding in '.$file[0].'
';
138 | $allWrongEnc++;
139 | }
140 | }
141 | }
142 | $regex->next();
143 | }
144 | echo "
All files with wrong encoding: $allWrongEnc
";
145 | }
146 |
147 | include_once 'footer.php';
148 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Saibamen/ReactOS-Translation-Tool/baa6eaee8304f76547ad6d4e00b2323cb344e695/favicon.ico
--------------------------------------------------------------------------------
/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Saibamen/ReactOS-Translation-Tool/baa6eaee8304f76547ad6d4e00b2323cb344e695/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Saibamen/ReactOS-Translation-Tool/baa6eaee8304f76547ad6d4e00b2323cb344e695/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Saibamen/ReactOS-Translation-Tool/baa6eaee8304f76547ad6d4e00b2323cb344e695/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Saibamen/ReactOS-Translation-Tool/baa6eaee8304f76547ad6d4e00b2323cb344e695/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/footer.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
14 |