Merge lp:~quam-plures-core/quam-plures/bp-i18n-reorder-miscfiles into lp:quam-plures/misc

Proposed by Tilman Blumenbach
Status: Merged
Merged at revision: 6
Proposed branch: lp:~quam-plures-core/quam-plures/bp-i18n-reorder-miscfiles
Merge into: lp:quam-plures/misc
Diff against target: 164 lines (+53/-15)
2 files modified
gettext/xg.bat (+2/-0)
gettext/xg.php (+51/-15)
To merge this branch: bzr merge lp:~quam-plures-core/quam-plures/bp-i18n-reorder-miscfiles
Reviewer Review Type Date Requested Status
Yabs (community) Approve
Review via email: mp+24950@code.launchpad.net
To post a comment you must log in.
Revision history for this message
EdB (edb) wrote :

getting now, will test to the best of my abilities later on today ... maybe tomorrow morning

Revision history for this message
EdB (edb) wrote :

Yabs this one is on you :)

Revision history for this message
Yabs (yabs) wrote :

heh

What the hell do I know about foreign languages? apart from the fact that the yanks remove u from most of the best words and the aussies add a rising inflection to everything just in case they missed the point :|

/me takes the easy route ... approved, but if it kills stuff you fix it ;)

¥

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-03-14 12:51:28 +0000
3+++ gettext/xg.bat 2010-05-08 20:28:28 +0000
4@@ -1,5 +1,7 @@
5 @echo off
6
7+REM *** NOTE: This file is unmaintained and will not work. ***
8+
9 REM xg.bat - Generate POT file.
10 REM Invoke this batch file in the application root directory (or the
11 REM directory where your plugin file resides).
12
13=== modified file 'gettext/xg.php'
14--- gettext/xg.php 2010-03-14 01:04:28 +0000
15+++ gettext/xg.php 2010-05-08 20:28:28 +0000
16@@ -44,7 +44,7 @@
17 echo ' ', $my_basename, ' [-b <app_root>] <CORE|CWD> merge <locale> [locale..]', "\n";
18 echo ' ', $my_basename, ' [-b <app_root>] <CORE|CWD> convert <locale> [locale..]', "\n\n";
19 echo 'CORE: work on the core application.', "\n";
20- echo 'CWD : work on current working directory.', "\n";
21+ echo 'CWD : work on current working directory (plugin mode).', "\n";
22 echo "\n";
23 echo 'By default, the translatable strings get extracted into locales/messages.POT.', "\n";
24 echo "\n";
25@@ -104,14 +104,14 @@
26 switch( strtoupper($argv[1]) )
27 {
28 case 'CORE':
29- echo 'CORE mode..', "\n";
30+ echo 'CORE mode...', "\n";
31 $mode = 'CORE';
32 // Our root directory is the application root directory:
33 $dir_root = $_app_root;
34 break;
35
36 case 'CWD':
37- echo 'Using current working directory..', "\n";
38+ echo 'Using current working directory (plugin mode)...', "\n";
39 $mode = 'CWD';
40 $dir_root = getcwd();
41 break;
42@@ -169,19 +169,29 @@
43 $dir_root = str_replace('\\', '/', $dir_root);
44
45 // The messages.pot (template) file:
46-$file_pot = $dir_root.'locales/messages.pot';
47+if( $mode == 'CORE' )
48+{
49+ $file_pot = $locales_path;
50+}
51+else
52+{ // Plugin mode:
53+ $file_pot = $dir_root.'po/';
54+}
55+$file_pot .= 'messages.pot';
56
57 if( $action == 'extract' )
58 {
59 if( ! is_writable($file_pot) )
60 {
61- if( ! file_exists( $dir_root.'locales' ) )
62+ $locale_dir = dirname( $file_pot );
63+
64+ if( ! file_exists( $locale_dir ) )
65 {
66- echo 'Directory [', $dir_root, 'locales/] does not exist..', "\n";
67+ echo 'Directory [', $locale_dir, '] does not exist..', "\n";
68
69- if( ! mkdir( $dir_root.'locales' ) )
70+ if( ! mkdir( $locale_dir ) )
71 {
72- die( 'FATAL: could not create directory ['.$dir_root.'locales/]!'."\n" );
73+ die( 'FATAL: could not create directory ['.$locale_dir.']!'."\n" );
74 }
75 echo 'Created directory.', "\n";
76 }
77@@ -202,13 +212,13 @@
78 if( isset($argv[3]) )
79 { // File(s) specified
80 echo 'Extracting T_() and NT_() strings from given files below "';
81- echo $dir_root_basename, '" into "', $dir_root_basename, '/locales/messages.pot".. ';
82+ echo $dir_root_basename, '" into "', $file_pot, '"... ';
83 $cmd = '';
84 }
85 else
86 {
87 echo 'Extracting T_() and NT_() strings from all .php files below "';
88- echo $dir_root_basename, '" into "', $dir_root_basename, '/locales/messages.pot".. ';
89+ echo $dir_root_basename, '" into "', $file_pot, '"... ';
90
91 // Change working dir (to simplify exlude patterns below):
92 chdir( $dir_root );
93@@ -248,8 +258,8 @@
94 $data = file_get_contents( $file_pot );
95
96 $data = str_replace( "\r", '', $data );
97+
98 // Make paths relative:
99-
100 if( isset( $argv[3] ) )
101 { // File names given
102 $rep_path = $dir_root;
103@@ -258,7 +268,7 @@
104 { // Core mode (prepend root path to file names in POT file):
105 $rep_path = '';
106 }
107- $data = preg_replace( '~^#: .*$~me', 'str_replace( \' '.$rep_path.'\', \' ../../../\', \'$0\' )', $data );
108+ $data = preg_replace( '~^#: .*$~me', 'str_replace( \' '.$rep_path.'\', \' ../\', \'$0\' )', $data );
109
110 file_put_contents( $file_pot, $data );
111
112@@ -292,7 +302,15 @@
113
114 foreach( $_locales as $l_locale )
115 {
116- $l_file_po = $dir_root.'locales/'.$l_locale.'/LC_MESSAGES/messages.po';
117+ if( $mode == 'CORE' )
118+ {
119+ $l_file_po = $locales_path;
120+ }
121+ else
122+ { // Plugin mode:
123+ $l_file_po = $dir_root.'/po/';
124+ }
125+ $l_file_po .= $l_locale.'.po';
126
127 echo 'Merging with '.$l_locale.'.. ';
128
129@@ -319,8 +337,20 @@
130
131 foreach( $_locales as $l_locale )
132 {
133- $l_file_po = $dir_root.'locales/'.$l_locale.'/LC_MESSAGES/messages.po';
134- $global_file_path = $dir_root.'locales/'.$l_locale.'/_global.php';
135+ if( $mode == 'CORE' )
136+ {
137+ $l_file_po = $locales_path;
138+ $global_file_dir = $locales_path;
139+ }
140+ else
141+ { // Plugin mode...
142+ $l_file_po = $dir_root.'po/';
143+ $global_file_dir = $dir_root.'po/';
144+ }
145+
146+ $l_file_po .= $l_locale.'.po';
147+ $global_file_dir .= 'php/'.$l_locale;
148+ $global_file_path = $global_file_dir.'/_global.php';
149
150 echo 'Converting '.$l_locale.'.. ';
151
152@@ -329,6 +359,12 @@
153 echo 'PO file [', $l_file_po, '] not found!', "\n";
154 continue;
155 }
156+ else if( ! file_exists( $global_file_dir ) &&
157+ ! mkdir( $global_file_dir, 0777, true ) )
158+ {
159+ echo 'Could not create directory [', $global_file_dir, ']!', "\n";
160+ continue;
161+ }
162
163 $POFile = new POFile($l_file_po);
164 $POFile->read(false);

Subscribers

People subscribed via source and target branches

to all changes: