Merge lp:~quam-plures-core/quam-plures/bug-538197 into lp:quam-plures/misc

Proposed by Tilman Blumenbach
Status: Merged
Merged at revision: not available
Proposed branch: lp:~quam-plures-core/quam-plures/bug-538197
Merge into: lp:quam-plures/misc
Diff against target: 612 lines (+235/-212)
2 files modified
gettext/xg.bat (+61/-19)
gettext/xg.php (+174/-193)
To merge this branch: bzr merge lp:~quam-plures-core/quam-plures/bug-538197
Reviewer Review Type Date Requested Status
EdB Approve
Tilman Blumenbach (community) Abstain
Review via email: mp+21276@code.launchpad.net

Commit message

Merged bug-538197.

To post a comment you must log in.
Revision history for this message
EdB (edb) wrote :

Not sure how I could test this so I won't, but wanted to mention that I will be taking care of the_pofile.class.php file in the main package.

Correct me if I'm wrong, but this is how one would extract the actual strings (if one did not want to use a .bat file)? pofile.class.php seems to create the _global.php file for each locale, and it still writes "if evo_main_whatever is undefined" plus a few other uncool bits.

Revision history for this message
EdB (edb) wrote :

Oh and I couldn't merge this if I wanted to but I say it's cool so someone should merge it. At least I think I can't merge it... I know I can say it is okay because see how I just did :)

review: Approve
Revision history for this message
Tilman Blumenbach (tblue) wrote :

> Correct me if I'm wrong, but this is how one would extract the actual strings (if one did not want to use a .bat file)?
Yes.

> pofile.class.php seems to create the _global.php file for each locale, and it still writes "if evo_main_whatever is undefined" plus a few other uncool bits.
Hmm, looks like it uses QP_MAIN_INIT already.

Revision history for this message
EdB (edb) wrote :

Yeah I type then think is the thing. The Turkish translation had it so I wondered where it came from. It came from getting Turkish from evoland :)

The change I made to _pofile is to very simply add a @package line for happy autodocs ... which I now realize I forgot to add to the files prior to pushing the restored localizations. Sheesh!

Revision history for this message
EdB (edb) wrote :

hmmm... maybe I could merge this but I'm not going to try. Got one thing done today I didn't know how to do, so I don't want to push my luck. Yabs?

Revision history for this message
EdB (edb) wrote :

I thought of a problem with this but it might not be depending on exactly how you got it working. The files in the /templates/ folder are "core" and therefore need to be translated with everything else. The folders (the actual templates) are the ones that "core translation" should be not doing. So for my method "remove plugins folder, remove all the folders in the templates folder, do the batch file thing". For this smart method it means a smarter smart line to exclude folders in a folder.

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Okay, I will look at this. Consider this proposal to be "on hold".

Revision history for this message
Tilman Blumenbach (tblue) wrote :

So this turned into a major overhaul of gettext/xg.php. I tested most of it.

review: Needs Resubmitting
Revision history for this message
Tilman Blumenbach (tblue) wrote :

Still working on the batch file...

Revision history for this message
Tilman Blumenbach (tblue) :
review: Abstain
Revision history for this message
Tilman Blumenbach (tblue) wrote :

Batch files are very limited, but the new batch file at least does more than the previous one. I think I'm done.

14. By Tilman Blumenbach

Added plugin and core mode to xg.bat

Revision history for this message
EdB (edb) wrote :

If Yabs doesn't merge this I'll see if I can. Not sure if I have perms or not, but if so I can probably figure out how to get it done. Would be better if Yabs took care of it though.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gettext/xg.bat'
2--- gettext/xg.bat 2010-01-27 18:27:00 +0000
3+++ gettext/xg.bat 2010-03-14 12:54:25 +0000
4@@ -1,19 +1,61 @@
5-@echo off
6-
7-echo Generate file list.
8-dir /b /s ..\blogs\*.php > files.txt
9-
10-echo Extract strings.
11-xgettext -D ../blogs/ -f files.txt --no-wrap --add-comments=TRANS --copyright-holder="Francois PLANQUE" --msgid-bugs-address=http://fplanque.net/ --output=..\blogs\locales\messages.pot --keyword=T_ --keyword=NT_ --keyword=TS_
12-
13-echo Correct paths.
14-xchangecl +d! ..\blogs\locales\messages.pot !D:\www\b2cvs20\blogs\!..\..\..\!
15-
16-echo Correct Header.
17-xchangecl +d! -t# ..\blogs\locales\messages.pot !#35##32#SOME#32#DESCRIPTIVE#32#TITLE.!#35##32#b2evolution#32#-#32#Language#32#file!#35##32#This#32#file#32#is#32#distributed#32#under#32#the#32#same#32#license#32#as#32#the#32#PACKAGE#32#package.!#35##32#This#32#file#32#is#32#distributed#32#under#32#the#32#same#32#license#32#as#32#the#32#b2evolution#32#package.!"Content-Type:#32#text/plain;#32#charset=CHARSET\n"!"Content-Type:#32#text/plain;#32#charset=iso-8859-1\n"!
18-
19-echo Merge with French.
20-msgmerge -U --no-wrap ..\blogs\locales\fr_FR\LC_MESSAGES\messages.po ..\blogs\locales\messages.pot
21-
22-REM echo Change comments.
23-REM xchangecl +d! -t# ..\blogs\locales\fr_FR\LC_MESSAGES\messages.po !#35#.#32#TRANS:!#35##32#TRANS:!
24+@echo off
25+
26+REM xg.bat - Generate POT file.
27+REM Invoke this batch file in the application root directory (or the
28+REM directory where your plugin file resides).
29+
30+REM This batch file requires the sed, xgettext and fart tools to be somewhere
31+REM in your Path.
32+REM sed is available from:
33+REM http://gnuwin32.sourceforge.net/packages/sed.htm
34+REM xgettext is available from:
35+REM http://gnuwin32.sourceforge.net/packages/gettext.htm
36+REM fart is available from:
37+REM http://fart-it.sourceforge.net/
38+
39+if /i "%1" equ "CORE" (
40+ goto MAIN
41+) else if /i "%1" equ "PLUGIN" (
42+ goto MAIN
43+) else (
44+ goto USAGE
45+)
46+
47+:MAIN
48+ REM Generate file list, make paths relative, filter excluded directories
49+ REM and extract strings:
50+ dir /s /b *.php | fart -qi - "%CD%" . ^
51+ | findstr /r /i /v ^
52+ "^\.\\templates\\[^\\]*\\.* ^\.\\plugins\\.* ^\.\\build\\.*" ^
53+ | xgettext -f - -o locales\messages.pot --from-code=iso-8859-15 ^
54+ --no-wrap --add-comments=TRANS "--copyright-holder=The Quam Plures developers" ^
55+ --msgid-bugs-address=http://quamplures.net/ --keyword=T_ ^
56+ --keyword=NT_ --keyword=TS_ -F
57+
58+ REM Make paths relative:
59+ sed -i "/^#: /{ s| \.| ..\\..\\..|g; }" locales\messages.pot
60+
61+ if /i "%1" equ "CORE" (
62+ REM Replace bulk header values with nicer ones.
63+ REM TODO: Make app name and current year dynamic. Replace app version as in xg.php.
64+ sed -i "1,20{ s/PACKAGE/Quam Plures/; s/# SOME DESCRIPTIVE TITLE./# Quam Plures - Language file/; s/(C) YEAR/(C) 2009-2010/; s/CHARSET/iso-8859-1/; }" ^
65+ locales\messages.pot
66+ )
67+
68+ REM Delete temporary sed files (bug in gnuwin32 port):
69+ del sed*
70+
71+ exit /b 0
72+
73+:USAGE
74+ echo Usage:
75+ echo ^ %0 ^<CORE^|PLUGIN^>
76+ echo.
77+ echo CORE : Work on the core application.
78+ echo PLUGIN: Work on a plugin.
79+ echo.
80+ echo In both modes, you have to invoke this script in the application's
81+ echo root directory or the directory which contains your plugin's PHP
82+ echo file, respectively.
83+
84+ exit /b 1
85\ No newline at end of file
86
87=== modified file 'gettext/xg.php'
88--- gettext/xg.php 2010-01-27 18:27:00 +0000
89+++ gettext/xg.php 2010-03-14 12:54:25 +0000
90@@ -4,11 +4,12 @@
91 * Create a new messages.POT file and update specified .po files.
92 *
93 * Uses find, xargs, sed, xgettext and msgmerge tools.
94+ * This only works on UNIXoid systems.
95 *
96 * This file is part of the Quam Plures project - {@link http://quamplures.net/}.
97 * See also {@link https://launchpad.net/quam-plures}.
98 *
99- * @copyright (c) 2009 by the Quam Plures developers - {@link http://quamplures.net/}
100+ * @copyright (c) 2009-2010 by the Quam Plures developers - {@link http://quamplures.net/}
101 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}.
102 * Parts of this file are copyright (c)2004 by Daniel HAHLER - {@link http://thequod.de/contact}.
103 *
104@@ -18,70 +19,81 @@
105 * Daniel HAHLER grants Francois PLANQUE the right to license
106 * Daniel HAHLER's contributions to this file and the b2evolution project
107 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
108- * }}
109+ * }
110 *
111 * @package internal
112 *
113- * @todo Add checks for format, headers and domain ("msgfmt -c")
114+ * @todo Add checks for format, headers and domain ("msgfmt -c").
115 *
116- * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
117+ * {@internal Below is a list of authors who have contributed to design/coding of this file:}
118 * @author blueyed: Daniel HAHLER.
119- *
120+ * @author Tblue: Tilman BLUMENBACH.
121 */
122
123-require_once dirname(__FILE__).'/../blogs/conf/_config.php';
124-
125-echo '** gettext helper tool for ', $app_name, ' **', "\n";
126-
127-// Check that all external tools are available:
128-foreach( array( 'xgettext', 'msgmerge', 'find', 'xargs', 'sed' ) as $testtool )
129-{
130- exec( $testtool.' --version', $output, $return );
131- if( $return !== 0 )
132- {
133- die( "This script needs the $testtool tool.\n" );
134- }
135-}
136-
137+// Cache script base name:
138+$my_basename = basename( $argv[0] );
139+// Set default application root directory:
140+$_app_root = dirname( __FILE__ ).'/../../trunk';
141
142 function echo_usage()
143 {
144- global $argv, $app_name;
145-
146- echo "Usage: \n";
147- echo basename($argv[0])." <CORE|CWD> [extract]\n";
148- echo basename($argv[0])." <CORE|CWD> merge <locale> [locale..]\n";
149- echo basename($argv[0])." <CORE|CWD> convert <locale> [locale..]\n";
150- echo "CORE: work on the core application\n";
151- echo "CWD: work on current working directory\n";
152- echo "\n";
153- echo "By default, to translatable strings get extracted into locales/messages.POT.\n";
154- echo "\n";
155- echo "By adding 'merge <locale>' to the command line arguments, you'll merge\n";
156- echo "the locale's messages.PO file with the messages.POT file. This is useful\n";
157- echo "after having updated the messages.POT file, obviously.\n";
158- echo "\n";
159- echo "By adding 'convert <locale>' to the command line arguments, you'll convert\n";
160- echo 'the locale\'s messages.PO file to _global.php, which ', $app_name, " uses.\n";
161- echo "\n";
162- echo "E.g.,\n";
163- echo " php -f xg.php CORE\n";
164- echo " php -f xg.php CORE merge de_DE\n";
165- echo " ..edit .po file..\n";
166- echo " php -f xg.php CORE convert de_DE\n";
167- echo "\n";
168-}
169-
170-
171-if( ! isset($_SERVER['argc']) || ! isset( $_SERVER['argv'] ) )
172-{
173- echo_usage();
174- exit(1);
175-}
176-
177-
178-$argc = $_SERVER['argc'];
179-$argv = $_SERVER['argv'];
180+ global $argv, $app_name, $my_basename, $_app_root;
181+
182+ echo 'Usage: ', "\n";
183+ echo ' ', $my_basename, ' [-b <app_root>] <CORE|CWD> [extract]', "\n";
184+ echo ' ', $my_basename, ' [-b <app_root>] <CORE|CWD> merge <locale> [locale..]', "\n";
185+ echo ' ', $my_basename, ' [-b <app_root>] <CORE|CWD> convert <locale> [locale..]', "\n\n";
186+ echo 'CORE: work on the core application.', "\n";
187+ echo 'CWD : work on current working directory.', "\n";
188+ echo "\n";
189+ echo 'By default, the translatable strings get extracted into locales/messages.POT.', "\n";
190+ echo "\n";
191+ echo 'By adding \'merge <locale>\' to the command line arguments, you\'ll merge', "\n";
192+ echo 'the locale\'s messages.PO file with the messages.POT file. This is useful', "\n";
193+ echo 'after having updated the messages.POT file, obviously.', "\n";
194+ echo "\n";
195+ echo 'By adding \'convert <locale>\' to the command line arguments, you\'ll convert', "\n";
196+ echo 'the locale\'s messages.PO file to _global.php, which ', $app_name, ' uses.', "\n";
197+ echo "\n";
198+ echo 'E.g.:', "\n";
199+ echo ' php ', $my_basename, ' CORE', "\n";
200+ echo ' php ', $my_basename, ' CORE merge de_DE', "\n";
201+ echo ' ..edit .po file..', "\n";
202+ echo ' php ', $my_basename, ' CORE convert de_DE', "\n";
203+ echo "\n";
204+ echo 'This script expects the ', $app_name, ' root directory to be at [', $_app_root, '].', "\n";
205+ echo 'You can specify an alternative root directory using the -b option, e. g.:', "\n";
206+ echo ' php ', $my_basename, ' -b ../blogs CORE', "\n";
207+ echo '...but if you are reading this message, the root directory is set correctly.', "\n";
208+}
209+
210+
211+// Allow overriding of the application root directory via command line (-b option):
212+$opts = getopt( 'b:' );
213+if( isset( $opts['b'] ) )
214+{
215+ $_app_root = $opts['b'];
216+
217+ // Silently modify $argc and $argv:
218+ $argc -= 2;
219+ // This will fail if somebody passes an argument with more than one
220+ // option, e. g. "-bar".
221+ array_splice( $argv, array_search( '-b', $argv ), 2 );
222+
223+ //var_dump( $argc, $argv );
224+}
225+
226+if( ! is_dir( $_app_root ) )
227+{
228+ echo 'Error: Application root directory [', $_app_root, '] does not exist!', "\n";
229+ echo 'You can specify an alternative root directory by using the -b option:', "\n";
230+ echo ' php ', $my_basename, ' -b /path/to/application/root/directory CORE', "\n";
231+ exit( 2 );
232+}
233+
234+require_once $_app_root.'/conf/_config.php';
235+
236+echo '** gettext helper tool for ', $app_name, ' **', "\n\n";
237
238 if( $argc < 2 )
239 {
240@@ -89,65 +101,66 @@
241 exit(1);
242 }
243
244-if( strtoupper($argv[1]) == 'CORE' )
245-{
246- echo "CORE mode..\n";
247- $mode = 'CORE';
248- // The blogs directory:
249- $dir_root = dirname(__FILE__).'/../blogs/';
250-}
251-elseif( strtoupper($argv[1]) == 'CWD' )
252-{
253- echo "Using current working directory..\n";
254- $mode = 'CWD';
255- $dir_root = getcwd();
256-}
257-else
258-{
259- echo_usage();
260- exit(1);
261-}
262-
263-if( ! isset($argv[2]) || strtoupper($argv[2]) == 'EXTRACT' )
264-{
265- $action = 'extract';
266-}
267-elseif( isset($argv[2]) && strtoupper($argv[2]) == 'MERGE' )
268-{
269- $action = 'merge';
270-
271- if( ! isset($argv[3]) ) // the to-get-merged locale
272- {
273- echo_usage();
274- exit(1);
275- }
276-
277- $locales_to_merge = array_slice( $argv, 3 );
278-}
279-elseif( isset($argv[2]) && strtoupper($argv[2]) == 'CONVERT' )
280-{
281- $action = 'convert';
282-
283- if( ! isset($argv[3]) ) // the to-get-converted locale
284- {
285- echo_usage();
286- exit(1);
287- }
288-
289- $locales_to_convert = array_slice( $argv, 3 );
290-}
291-else
292-{
293- echo_usage();
294- die;
295-}
296-
297+switch( strtoupper($argv[1]) )
298+{
299+ case 'CORE':
300+ echo 'CORE mode..', "\n";
301+ $mode = 'CORE';
302+ // Our root directory is the application root directory:
303+ $dir_root = $_app_root;
304+ break;
305+
306+ case 'CWD':
307+ echo 'Using current working directory..', "\n";
308+ $mode = 'CWD';
309+ $dir_root = getcwd();
310+ break;
311+
312+ default:
313+ echo_usage();
314+ exit(1);
315+}
316+
317+$action = 'extract';
318+if( isset($argv[2]) )
319+{
320+ $action = strtolower( $argv[2] );
321+
322+ if( ! in_array( $action, array( 'extract', 'merge', 'convert' ) ) )
323+ {
324+ echo_usage();
325+ exit( 1 );
326+ }
327+ else if( $action == 'convert' || $action == 'merge' )
328+ {
329+ if( ! isset($argv[3]) )
330+ {
331+ echo_usage();
332+ exit(1);
333+ }
334+
335+ $_locales = array_slice( $argv, 3 );
336+ }
337+}
338
339 // ---- COMMON CHECKS: ----
340
341-if( ! realpath($dir_root) )
342-{
343- die( "Fatal error: The path '$dir_root' was not found!\n" );
344+if( $action != 'convert' )
345+{
346+ // Check that all external tools are available:
347+ foreach( array( 'xgettext', 'msgmerge', 'find', 'xargs', 'sed' ) as $testtool )
348+ {
349+ exec( $testtool.' --version 2>/dev/null', $output, $return );
350+ if( $return == 127 )
351+ { // Command not found (return code specified by POSIX):
352+ die( 'This script needs the '.$testtool.' tool.'."\n" );
353+ }
354+ }
355+}
356+
357+if( ! is_dir($dir_root) )
358+{
359+ die( 'Fatal error: The path ['.$dir_root.'] was not found!'."\n" );
360 }
361 // Normalize path:
362 $dir_root = realpath($dir_root).'/';
363@@ -158,20 +171,19 @@
364 // The messages.pot (template) file:
365 $file_pot = $dir_root.'locales/messages.pot';
366
367-
368 if( $action == 'extract' )
369 {
370 if( ! is_writable($file_pot) )
371 {
372 if( ! file_exists( $dir_root.'locales' ) )
373 {
374- echo "Directory {$dir_root}locales/ does not exist..\n";
375+ echo 'Directory [', $dir_root, 'locales/] does not exist..', "\n";
376
377 if( ! mkdir( $dir_root.'locales' ) )
378 {
379- die( "FATAL: could not create directory {$dir_root}locales/\n" );
380+ die( 'FATAL: could not create directory ['.$dir_root.'locales/]!'."\n" );
381 }
382- echo "Created directory.\n";
383+ echo 'Created directory.', "\n";
384 }
385
386 if( ! file_exists( $file_pot ) )
387@@ -182,69 +194,89 @@
388
389 if( ! is_writable($file_pot) )
390 {
391- die( "FATAL: The file $file_pot is not writable.\n" );
392+ die( 'FATAL: The file ['.$file_pot.'] is not writable.'."\n" );
393 }
394 }
395
396- // The locales dir is our working dir:
397-# chdir( $dir_root.'locales' );
398-
399+ $dir_root_basename = basename($dir_root);
400 if( isset($argv[3]) )
401 { // File(s) specified
402+ echo 'Extracting T_() and NT_() strings from given files below "';
403+ echo $dir_root_basename, '" into "', $dir_root_basename, '/locales/messages.pot".. ';
404 $cmd = '';
405- echo 'Extracting T_() and NT_() strings from given files below "'.basename($dir_root).'" into "'.basename($dir_root).'/locales/messages.pot".. ';
406 }
407 else
408 {
409- echo 'Extracting T_() and NT_() strings from all .php files below "'.basename($dir_root).'" into "'.basename($dir_root).'/locales/messages.pot".. ';
410- # find *.php files, but not in "build" directory:
411- $cmd = 'find '.escapeshellarg($dir_root).' -wholename "*/build/*" -prune -o \( -iname "*.php" -print \) | xargs ';
412+ echo 'Extracting T_() and NT_() strings from all .php files below "';
413+ echo $dir_root_basename, '" into "', $dir_root_basename, '/locales/messages.pot".. ';
414+
415+ // Change working dir (to simplify exlude patterns below):
416+ chdir( $dir_root );
417+
418+ /* Find *.php files, but exclude:
419+ * - all directories below templates/
420+ * - the plugins/ directory
421+ * - the build/ directory
422+ */
423+ $cmd = 'find . \\( ';
424+ $cmd .= '-path \'./templates/*[!/]/*\' -o -path \'./plugins/*\' -o -path \'./build/*\'';
425+ $cmd .= ' \\) -prune -o \\( -iname \'*.php\' -print0 \\) | xargs -0 ';
426 }
427- $cmd .= 'xgettext -o '.escapeshellarg($file_pot).' --from-code=iso-8859-15 --no-wrap --add-comments=TRANS --copyright-holder="Francois PLANQUE" --msgid-bugs-address=http://fplanque.net/ --keyword=T_ --keyword=NT_ --keyword=TS_ -F';
428+ $cmd .= 'xgettext -o '.escapeshellarg($file_pot).' --from-code=iso-8859-15 --no-wrap --add-comments=TRANS --copyright-holder="The Quam Plures developers" --msgid-bugs-address=http://quamplures.net/ --keyword=T_ --keyword=NT_ --keyword=TS_ -F';
429
430 // Append filenames, if specified:
431 if( isset($argv[3]) )
432 {
433- for( $i = 3; $i < count($argv); $i++ )
434+ $n = count($argv);
435+ for( $i = 3; $i < $n; $i++ )
436 {
437 $cmd .= ' '.escapeshellarg($argv[$i]);
438 }
439 }
440
441+ //echo 'Command: [', $cmd, ']', "\n";
442 system( $cmd, $return_var );
443 if( $return_var !== 0 )
444 {
445- die("Failed!\n");
446+ die('Command failed (return code: '.$return_var.')!'."\n");
447 }
448 echo "[ok]\n";
449
450
451 // Replace various things (see comments)
452- echo 'Automagically search&replace in messages.pot.. ';
453+ echo 'Automagically search & replace in messages.pot.. ';
454 $data = file_get_contents( $file_pot );
455
456 $data = str_replace( "\r", '', $data );
457 // Make paths relative:
458- $data = preg_replace( '~^#: .*$~me', 'str_replace( \' '.$dir_root.'\', \' ../../../\', \'$0\' )', $data );
459+
460+ if( isset( $argv[3] ) )
461+ { // File names given
462+ $rep_path = $dir_root;
463+ }
464+ else
465+ { // Core mode (prepend root path to file names in POT file):
466+ $rep_path = '';
467+ }
468+ $data = preg_replace( '~^#: .*$~me', 'str_replace( \' '.$rep_path.'\', \' ../../../\', \'$0\' )', $data );
469
470 file_put_contents( $file_pot, $data );
471
472 if( $mode == 'CORE' )
473 { // Replace header "vars" in first 20 lines:
474- system( 'sed -i 1,20"'
475+ system( 'sed -i "1,20{'
476 .'s/PACKAGE/'.$app_name.'/;'
477 .'s/VERSION/'.$app_version.'/;'
478 .'s/# SOME DESCRIPTIVE TITLE./# '.$app_name.' - Language file/;'
479- .'s/(C) YEAR/(C) 2003-'.date('Y').'/;'
480- .'s/YEAR(?!-MO)/'.date('Y').'/;'
481+ .'s/(C) YEAR/(C) 2009-'.date('Y').'/;'
482 .'s/CHARSET/iso-8859-1/;'
483- .'" '.escapeshellarg($file_pot) );
484+ .'}" '.escapeshellarg($file_pot) );
485 }
486 else
487 {
488 // TODO: try to detect usage with a plugin and s&r accordingly
489 }
490- echo "[ok]\n";
491+ echo '[ok]', "\n";
492
493 exit(0);
494 }
495@@ -254,11 +286,11 @@
496 { // Merge with existing .po files:
497 if( ! @is_readable( $file_pot ) )
498 {
499- echo "FATAL: $file_pot is not readable!\n";
500+ echo 'FATAL: [', $file_pot, '] is not readable!', "\n";
501 exit(1);
502 }
503
504- foreach( $locales_to_merge as $l_locale )
505+ foreach( $_locales as $l_locale )
506 {
507 $l_file_po = $dir_root.'locales/'.$l_locale.'/LC_MESSAGES/messages.po';
508
509@@ -266,14 +298,14 @@
510
511 if( ! file_exists( $l_file_po ) )
512 {
513- echo "PO file $l_file_po not found!\n";
514+ echo 'PO file [', $l_file_po, '] not found!', "\n";
515 continue;
516 }
517
518 system( 'msgmerge -U -F --no-wrap '.escapeshellarg($l_file_po).' '.escapeshellarg($file_pot) );
519 # delete old TRANS comments and make automatic ones valid comments:
520 system( 'sed -i -r "/^#\\s+TRANS:/d; s/^#\\. TRANS:/# TRANS:/;" '.$l_file_po );
521- echo "Written $l_file_po .\n";
522+ echo 'Written [', $l_file_po, '].', "\n";
523 echo "\n";
524 }
525
526@@ -283,9 +315,9 @@
527
528 if( $action == 'convert' )
529 { // convert messages.PO files to _global.php
530- require_once dirname(__FILE__).'/../blogs/inc/locales/_pofile.class.php';
531+ require_once $_app_root.'/inc/locales/_pofile.class.php';
532
533- foreach( $locales_to_convert as $l_locale )
534+ foreach( $_locales as $l_locale )
535 {
536 $l_file_po = $dir_root.'locales/'.$l_locale.'/LC_MESSAGES/messages.po';
537 $global_file_path = $dir_root.'locales/'.$l_locale.'/_global.php';
538@@ -294,7 +326,7 @@
539
540 if( !file_exists( $l_file_po ) )
541 {
542- echo "PO file $l_file_po not found!\n";
543+ echo 'PO file [', $l_file_po, '] not found!', "\n";
544 continue;
545 }
546
547@@ -304,63 +336,12 @@
548
549 if( $r !== true )
550 {
551- echo "Error: $r\n";
552+ echo 'Error: ', $r, "\n";
553 continue;
554 }
555
556- echo "[ok]\n";
557+ echo '[ok]', "\n";
558 }
559
560 exit(0);
561 }
562-
563-
564-/**
565- * From {@link http://de.php.net/manual/en/function.realpath.php#77203}
566- */
567-function rel_path($dest, $root = '')
568-{
569- $root = explode(DIRECTORY_SEPARATOR, $root);
570- $dest = explode(DIRECTORY_SEPARATOR, $dest);
571- $path = '.';
572- $fix = '';
573- $diff = 0;
574- for($i = -1; ++$i < max(($rC = count($root)), ($dC = count($dest)));)
575- {
576- if(isset($root[$i]) and isset($dest[$i]))
577- {
578- if($diff)
579- {
580- $path .= DIRECTORY_SEPARATOR. '..';
581- $fix .= DIRECTORY_SEPARATOR. $dest[$i];
582- continue;
583- }
584- if($root[$i] != $dest[$i])
585- {
586- $diff = 1;
587- $path .= DIRECTORY_SEPARATOR. '..';
588- $fix .= DIRECTORY_SEPARATOR. $dest[$i];
589- continue;
590- }
591- }
592- elseif(!isset($root[$i]) and isset($dest[$i]))
593- {
594- for($j = $i-1; ++$j < $dC;)
595- {
596- $fix .= DIRECTORY_SEPARATOR. $dest[$j];
597- }
598- break;
599- }
600- elseif(isset($root[$i]) and !isset($dest[$i]))
601- {
602- for($j = $i-1; ++$j < $rC;)
603- {
604- $fix = DIRECTORY_SEPARATOR. '..'. $fix;
605- }
606- break;
607- }
608- }
609- return $path. $fix;
610-}
611-
612-?>

Subscribers

People subscribed via source and target branches

to all changes: