Révision 3447
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/ExternalizationFilesUpdater.groovy (revision 3447) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
|
|
22 |
// |
|
23 |
// This file is part of the TXM platform. |
|
24 |
// |
|
25 |
// The TXM platform is free software: you can redistribute it and/or modif y |
|
26 |
// it under the terms of the GNU General Public License as published by |
|
27 |
// the Free Software Foundation, either version 3 of the License, or |
|
28 |
// (at your option) any later version. |
|
29 |
// |
|
30 |
// The TXM platform is distributed in the hope that it will be useful, |
|
31 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
// GNU General Public License for more details. |
|
34 |
// |
|
35 |
// You should have received a copy of the GNU General Public License |
|
36 |
// along with the TXM platform. If not, see <http://www.gnu.org/licenses/>. |
|
37 |
// |
|
38 |
// |
|
39 |
// |
|
40 |
// $LastChangedDate: 2013-07-25 16:24:13 +0200 (jeu. 25 juil. 2013) $ |
|
41 |
// $LastChangedRevision: 2490 $ |
|
42 |
// $LastChangedBy: mdecorde $ |
|
43 |
// |
|
44 |
package org.txm.rcp.translate.i18n; |
|
45 |
|
|
46 |
import java.io.BufferedReader; |
|
47 |
import java.io.File; |
|
48 |
import java.io.FileInputStream; |
|
49 |
import java.io.InputStreamReader; |
|
50 |
import java.util.LinkedList; |
|
51 |
|
|
52 |
import org.txm.utils.io.IOUtils |
|
53 |
|
|
54 |
// TODO: Auto-generated Javadoc |
|
55 |
/** |
|
56 |
* Tool to update the key of externalization files xxxx_fr.properties |
|
57 |
* adds _NA to missing keys |
|
58 |
* |
|
59 |
* @author mdecorde |
|
60 |
* |
|
61 |
*/ |
|
62 |
public class ExternalizationFilesUpdater { |
|
63 |
|
|
64 |
/** The dirfiles. */ |
|
65 |
LinkedList<File> dirfiles = new LinkedList<File>(); |
|
66 |
|
|
67 |
/** The propertyfiles. */ |
|
68 |
HashMap<String, File> propertyfiles = new HashMap<String, File>(); |
|
69 |
|
|
70 |
/** The fileentries. */ |
|
71 |
HashMap<File, List<String>> fileentries = new HashMap<String, List<String>>(); |
|
72 |
|
|
73 |
/** The fileentriesvalues. */ |
|
74 |
HashMap<File, HashMap<String, String>> fileentriesvalues = new HashMap<String, HashMap<String, String>>(); |
|
75 |
|
|
76 |
/** |
|
77 |
* Gets the entries. |
|
78 |
* |
|
79 |
* @param file the file |
|
80 |
* @return the entries |
|
81 |
*/ |
|
82 |
public List<String> getEntries(File file) |
|
83 |
{ |
|
84 |
List<String> entries = []; |
|
85 |
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file) , "iso-8859-1")); |
|
86 |
String line = reader.readLine(); |
|
87 |
while (line != null) { |
|
88 |
String[] split = line.split("=", 2); |
|
89 |
if (split.length > 0) { |
|
90 |
String key = split[0]; |
|
91 |
entries.add(key); |
|
92 |
} |
|
93 |
line = reader.readLine(); |
|
94 |
} |
|
95 |
return entries; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Gets the values. |
|
100 |
* |
|
101 |
* @param file the file |
|
102 |
* @return the values |
|
103 |
*/ |
|
104 |
public HashMap<String, String> getValues(File file) { |
|
105 |
HashMap<String, String> values = new HashMap<String, String>(); |
|
106 |
BufferedReader reader = new BufferedReader(new InputStreamReader( |
|
107 |
new FileInputStream(file), "iso-8859-1")); |
|
108 |
String line = reader.readLine(); |
|
109 |
while (line != null) { |
|
110 |
String[] split = line.split("="); |
|
111 |
if (split.length > 0) { |
|
112 |
String key = split[0]; |
|
113 |
String concat = ""; |
|
114 |
for (int i = 1; i < split.length; i++) |
|
115 |
concat += split[i]; |
|
116 |
values.put(key, concat); |
|
117 |
} |
|
118 |
line = reader.readLine(); |
|
119 |
} |
|
120 |
return values; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Process found directories. |
|
125 |
*/ |
|
126 |
public void processFoundDirectories() |
|
127 |
{ |
|
128 |
for (String dirfile : dirfiles) { |
|
129 |
println "DIRECTORY : "+dirfile |
|
130 |
List<File> files = propertyfiles.get(dirfile) |
|
131 |
for (File f : files) { |
|
132 |
this.fileentries.put(f, getEntries(f)); |
|
133 |
this.fileentriesvalues.put(f, getValues(f)); |
|
134 |
} |
|
135 |
File reference = null; |
|
136 |
if (files.get(0).getName().startsWith("m")) { |
|
137 |
reference = new File(dirfile,"messages.properties"); |
|
138 |
} |
|
139 |
else if (files.get(0).getName().startsWith("b")) |
|
140 |
reference = new File(dirfile,"bundle.properties"); |
|
141 |
|
|
142 |
if (reference != null && reference.exists()) { |
|
143 |
for (File f : files) { |
|
144 |
if (f != reference) { |
|
145 |
List<String> refentries = this.fileentries.get(reference).clone(); |
|
146 |
List<String> tmp1 = this.fileentries.get(f).clone(); |
|
147 |
tmp1.removeAll(refentries); |
|
148 |
|
|
149 |
refentries = this.fileentries.get(reference).clone(); |
|
150 |
List<String> tmp = this.fileentries.get(f); |
|
151 |
refentries.removeAll(tmp); |
|
152 |
for (String missing : refentries) { |
|
153 |
this.fileentriesvalues.get(f).put(missing,"N/A_"+this.fileentriesvalues.get(reference).get(missing)); // put entry's value |
|
154 |
} |
|
155 |
|
|
156 |
this.fileentries.put(f, this.fileentries.get(reference)); // update file entries |
|
157 |
|
|
158 |
if (tmp1.size() > 0 || refentries.size() > 0) |
|
159 |
println " "+f.getName() |
|
160 |
if (tmp1.size() > 0) |
|
161 |
println " Removed keys : "+tmp1; |
|
162 |
if (refentries.size() > 0) |
|
163 |
println " Added keys : "+refentries; |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
171 |
* Update files. |
|
172 |
*/ |
|
173 |
public void updateFiles() |
|
174 |
{ |
|
175 |
for(String dirfile : dirfiles) |
|
176 |
{ |
|
177 |
List<File> files = propertyfiles.get(dirfile); |
|
178 |
for(File f : files) |
|
179 |
{ |
|
180 |
List<String> entries = this.fileentries.get(f); |
|
181 |
HashMap<String, String> values = this.fileentriesvalues.get(f); |
|
182 |
|
|
183 |
Writer writer = new OutputStreamWriter(new FileOutputStream(f) , "iso-8859-1"); |
|
184 |
for(String entry : entries) |
|
185 |
{ |
|
186 |
writer.write(entry+"="+values.get(entry)+"\n"); |
|
187 |
} |
|
188 |
writer.close() |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* Creates the missing files. |
|
195 |
* |
|
196 |
* @param suffix the suffix |
|
197 |
*/ |
|
198 |
public void createMissingFiles(String suffix) |
|
199 |
{ |
|
200 |
println "Looking for missing messages files "+ suffix; |
|
201 |
for(String dirfile : dirfiles) |
|
202 |
{ |
|
203 |
//println "DIRECTORY : "+dirfile |
|
204 |
File reference = null; |
|
205 |
String lookingname = ""; |
|
206 |
List<File> files = propertyfiles.get(dirfile) |
|
207 |
if(files.get(0).getName().startsWith("m")) |
|
208 |
{ |
|
209 |
reference = new File(dirfile,"messages.properties"); |
|
210 |
lookingname = "messages_"+suffix+".properties" |
|
211 |
} |
|
212 |
else if (files.get(0).getName().startsWith("b")) |
|
213 |
{ |
|
214 |
reference = new File(dirfile,"bundle.properties"); |
|
215 |
lookingname = "bundle_"+suffix+".properties" |
|
216 |
} |
|
217 |
|
|
218 |
boolean create = true; |
|
219 |
if(reference != null && reference.exists()) |
|
220 |
{ |
|
221 |
for(File f : files) |
|
222 |
{ |
|
223 |
if(f.getName() == lookingname) |
|
224 |
create = false; |
|
225 |
} |
|
226 |
} |
|
227 |
if(create) |
|
228 |
{ |
|
229 |
new File(dirfile,lookingname).createNewFile(); |
|
230 |
println "Create file " +new File(dirfile,lookingname) |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
/* (non-Javadoc) |
|
236 |
* @see java.lang.Object#toString() |
|
237 |
*/ |
|
238 |
public String toString() |
|
239 |
{ |
|
240 |
String rez = ""; |
|
241 |
for(String dirfile : dirfiles) |
|
242 |
{ |
|
243 |
rez += dirfile+"\n"; |
|
244 |
for(File f : propertyfiles.get(dirfile)) |
|
245 |
rez += " "+f.getName()+"\n" |
|
246 |
} |
|
247 |
return rez; |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Scan directory. |
|
252 |
* |
|
253 |
* @param directory the directory |
|
254 |
*/ |
|
255 |
public void scanDirectory(File directory) |
|
256 |
{ |
|
257 |
if(!directory.exists()) |
|
258 |
{ |
|
259 |
println "directory '$directory' does not exists" |
|
260 |
return; |
|
261 |
} |
|
262 |
|
|
263 |
println "scan directory : "+directory.getAbsolutePath(); |
|
264 |
LinkedList<File> files = new LinkedList<File>(); |
|
265 |
files.add(directory); |
|
266 |
|
|
267 |
while(!files.isEmpty()) |
|
268 |
{ |
|
269 |
File current = files.removeFirst(); |
|
270 |
if(current.isDirectory()) |
|
271 |
{ |
|
272 |
List<String> currentpfiles = []; |
|
273 |
for(File sfile : current.listFiles(IOUtils.HIDDENFILE_FILTER)) |
|
274 |
{ |
|
275 |
if(sfile.isDirectory()) |
|
276 |
files.add(sfile); |
|
277 |
else if(sfile.getName().endsWith(".properties") && ( sfile.getName().startsWith("messages") || sfile.getName().startsWith("bundle")) ) |
|
278 |
currentpfiles.add(sfile) |
|
279 |
} |
|
280 |
if(currentpfiles.size() > 0) |
|
281 |
{ |
|
282 |
dirfiles.add(current.getAbsolutePath()); |
|
283 |
propertyfiles.put(current.getAbsolutePath(), currentpfiles); |
|
284 |
} |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
/** |
|
290 |
* The main method. |
|
291 |
* |
|
292 |
* @param args the arguments |
|
293 |
*/ |
|
294 |
public static void main(String[] args) |
|
295 |
{ |
|
296 |
String userdir = System.getProperty("user.home"); |
|
297 |
|
|
298 |
println "\nRCP\n"; |
|
299 |
|
|
300 |
ExternalizationFilesUpdater scanner = new ExternalizationFilesUpdater(); |
|
301 |
// scanner.scanDirectory(new File(userdir, "workspace37/org.txm.rcp")); // find directories with a messages.properties file |
|
302 |
// scanner.createMissingFiles("fr"); // create messages_fr.properties files when a messages.properties is found |
|
303 |
// scanner.processFoundDirectories(); // find missing and obsolets keys |
|
304 |
// scanner.updateFiles(); // update messages files content |
|
305 |
|
|
306 |
println "\nTOOLBOX\n"; |
|
307 |
|
|
308 |
scanner = new ExternalizationFilesUpdater(); |
|
309 |
scanner.scanDirectory(new File(userdir, "workspace43/org.txm.rcp/src/main/java")); |
|
310 |
scanner.createMissingFiles("fr"); |
|
311 |
scanner.createMissingFiles("ru"); |
|
312 |
scanner.processFoundDirectories(); |
|
313 |
scanner.updateFiles(); |
|
314 |
} |
|
315 |
} |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/FindUntranslatedMessages.groovy (revision 3447) | ||
---|---|---|
1 |
package org.txm.rcp.translate.i18n |
|
2 |
|
|
3 |
import org.txm.rcp.translate.i18n.ExternalizationFilesUpdater |
|
4 |
|
|
5 |
def userdir = System.getProperty("user.home") |
|
6 |
def workspace = new File(userdir, "workspace47") |
|
7 |
def langs = ["fr", "ru"] |
|
8 |
|
|
9 |
scanner = new ExternalizationFilesUpdater(); |
|
10 |
scanner.scanDirectory(new File(workspace, "org.txm.rcp")); |
|
11 |
for (def lang : langs) { |
|
12 |
scanner.createMissingFiles(lang); |
|
13 |
} |
|
14 |
scanner.processFoundDirectories(); |
|
15 |
scanner.updateFiles(); |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/IsStringMissingInPlugin.groovy (revision 3447) | ||
---|---|---|
10 | 10 |
|
11 | 11 |
public static void main(String[] args) { |
12 | 12 |
String userhome = System.getProperty("user.home") |
13 |
File propertyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties");
|
|
14 |
File copyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_copy.properties");
|
|
15 |
File pluginFile = new File(userhome, "workspace43/org.txm.rcp/plugin.xml");
|
|
13 |
File propertyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties");
|
|
14 |
File copyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_copy.properties");
|
|
15 |
File pluginFile = new File(userhome, "workspace047/org.txm.rcp/plugin.xml");
|
|
16 | 16 |
if (!(propertyFile.exists() && propertyFile.canRead() && propertyFile.canWrite() && propertyFile.isFile())) |
17 | 17 |
{ |
18 | 18 |
println "error file : "+propertyFile |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/ExternalizationFilesUpdater.java (revision 3447) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
|
|
22 |
// |
|
23 |
// This file is part of the TXM platform. |
|
24 |
// |
|
25 |
// The TXM platform is free software: you can redistribute it and/or modif y |
|
26 |
// it under the terms of the GNU General Public License as published by |
|
27 |
// the Free Software Foundation, either version 3 of the License, or |
|
28 |
// (at your option) any later version. |
|
29 |
// |
|
30 |
// The TXM platform is distributed in the hope that it will be useful, |
|
31 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
// GNU General Public License for more details. |
|
34 |
// |
|
35 |
// You should have received a copy of the GNU General Public License |
|
36 |
// along with the TXM platform. If not, see <http://www.gnu.org/licenses/>. |
|
37 |
// |
|
38 |
// |
|
39 |
// |
|
40 |
// $LastChangedDate: 2013-07-25 16:24:13 +0200 (jeu. 25 juil. 2013) $ |
|
41 |
// $LastChangedRevision: 2490 $ |
|
42 |
// $LastChangedBy: mdecorde $ |
|
43 |
// |
|
44 |
package org.txm.rcp.translate.i18n; |
|
45 |
|
|
46 |
import java.io.BufferedReader; |
|
47 |
import java.io.File; |
|
48 |
import java.io.FileInputStream; |
|
49 |
import java.io.FileNotFoundException; |
|
50 |
import java.io.FileOutputStream; |
|
51 |
import java.io.IOException; |
|
52 |
import java.io.InputStreamReader; |
|
53 |
import java.io.OutputStreamWriter; |
|
54 |
import java.io.UnsupportedEncodingException; |
|
55 |
import java.io.Writer; |
|
56 |
import java.util.ArrayList; |
|
57 |
import java.util.HashMap; |
|
58 |
import java.util.LinkedList; |
|
59 |
import java.util.List; |
|
60 |
|
|
61 |
import org.txm.utils.io.IOUtils; |
|
62 |
|
|
63 |
// TODO: Auto-generated Javadoc |
|
64 |
/** |
|
65 |
* Tool to update the key of externalization files xxxx_fr.properties |
|
66 |
* adds _NA to missing keys |
|
67 |
* |
|
68 |
* @author mdecorde |
|
69 |
* |
|
70 |
*/ |
|
71 |
public class ExternalizationFilesUpdater { |
|
72 |
|
|
73 |
/** The dirfiles. */ |
|
74 |
LinkedList<File> dirfiles = new LinkedList<File>(); |
|
75 |
|
|
76 |
/** The propertyfiles. */ |
|
77 |
HashMap<File, List<File>> propertyfiles = new HashMap<File, List<File>>(); |
|
78 |
|
|
79 |
/** The fileentries. */ |
|
80 |
HashMap<File, List<String>> fileentries = new HashMap<File, List<String>>(); |
|
81 |
|
|
82 |
/** The fileentriesvalues. */ |
|
83 |
HashMap<File, HashMap<String, String>> fileentriesvalues = new HashMap<File, HashMap<String, String>>(); |
|
84 |
|
|
85 |
/** |
|
86 |
* Gets the entries. |
|
87 |
* |
|
88 |
* @param file the file |
|
89 |
* @return the entries |
|
90 |
* @throws IOException |
|
91 |
*/ |
|
92 |
public List<String> getEntries(File file) throws IOException |
|
93 |
{ |
|
94 |
List<String> entries = new ArrayList<>(); |
|
95 |
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file) , "iso-8859-1")); |
|
96 |
String line = reader.readLine(); |
|
97 |
while (line != null) { |
|
98 |
String[] split = line.split("=", 2); |
|
99 |
if (split.length > 0) { |
|
100 |
String key = split[0]; |
|
101 |
entries.add(key); |
|
102 |
} |
|
103 |
line = reader.readLine(); |
|
104 |
} |
|
105 |
reader.close(); |
|
106 |
return entries; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Gets the values. |
|
111 |
* |
|
112 |
* @param file the file |
|
113 |
* @return the values |
|
114 |
* @throws IOException |
|
115 |
*/ |
|
116 |
public HashMap<String, String> getValues(File file) throws IOException { |
|
117 |
HashMap<String, String> values = new HashMap<String, String>(); |
|
118 |
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "iso-8859-1")); |
|
119 |
String line = reader.readLine(); |
|
120 |
while (line != null) { |
|
121 |
String[] split = line.split("="); |
|
122 |
if (split.length > 0) { |
|
123 |
String key = split[0]; |
|
124 |
String concat = ""; |
|
125 |
for (int i = 1; i < split.length; i++) |
|
126 |
concat += split[i]; |
|
127 |
values.put(key, concat); |
|
128 |
} |
|
129 |
line = reader.readLine(); |
|
130 |
} |
|
131 |
return values; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Process found directories. |
|
136 |
* @throws IOException |
|
137 |
*/ |
|
138 |
public void processFoundDirectories() throws IOException |
|
139 |
{ |
|
140 |
for (File dirfile : dirfiles) { |
|
141 |
System.out.println("DIRECTORY : "+dirfile); |
|
142 |
List<File> files = propertyfiles.get(dirfile); |
|
143 |
for (File f : files) { |
|
144 |
this.fileentries.put(f, getEntries(f)); |
|
145 |
this.fileentriesvalues.put(f, getValues(f)); |
|
146 |
} |
|
147 |
File reference = null; |
|
148 |
if (files.get(0).getName().startsWith("m")) { |
|
149 |
reference = new File(dirfile,"messages.properties"); |
|
150 |
} |
|
151 |
else if (files.get(0).getName().startsWith("b")) |
|
152 |
reference = new File(dirfile,"bundle.properties"); |
|
153 |
|
|
154 |
if (reference != null && reference.exists()) { |
|
155 |
for (File f : files) { |
|
156 |
if (f != reference) { |
|
157 |
List<String> refentries = new ArrayList<>(fileentries.get(reference)); |
|
158 |
List<String> tmp1 = new ArrayList<>(this.fileentries.get(f)); |
|
159 |
tmp1.removeAll(refentries); |
|
160 |
|
|
161 |
refentries = new ArrayList<>(this.fileentries.get(reference)); |
|
162 |
List<String> tmp = this.fileentries.get(f); |
|
163 |
refentries.removeAll(tmp); |
|
164 |
for (String missing : refentries) { |
|
165 |
this.fileentriesvalues.get(f).put(missing,"N/A_"+this.fileentriesvalues.get(reference).get(missing)); // put entry's value |
|
166 |
} |
|
167 |
|
|
168 |
this.fileentries.put(f, this.fileentries.get(reference)); // update file entries |
|
169 |
|
|
170 |
if (tmp1.size() > 0 || refentries.size() > 0) |
|
171 |
System.out.println( " "+f.getName()); |
|
172 |
if (tmp1.size() > 0) |
|
173 |
System.out.println(" Removed keys : "+tmp1); |
|
174 |
if (refentries.size() > 0) |
|
175 |
System.out.println(" Added keys : "+refentries); |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Update files. |
|
184 |
* @throws IOException |
|
185 |
*/ |
|
186 |
public void updateFiles() throws IOException |
|
187 |
{ |
|
188 |
for(File dirfile : dirfiles) |
|
189 |
{ |
|
190 |
List<File> files = propertyfiles.get(dirfile); |
|
191 |
for(File f : files) |
|
192 |
{ |
|
193 |
List<String> entries = this.fileentries.get(f); |
|
194 |
HashMap<String, String> values = this.fileentriesvalues.get(f); |
|
195 |
|
|
196 |
Writer writer = new OutputStreamWriter(new FileOutputStream(f) , "iso-8859-1"); |
|
197 |
for(String entry : entries) |
|
198 |
{ |
|
199 |
writer.write(entry+"="+values.get(entry)+"\n"); |
|
200 |
} |
|
201 |
writer.close(); |
|
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Creates the missing files. |
|
208 |
* |
|
209 |
* @param suffix the suffix |
|
210 |
* @throws IOException |
|
211 |
*/ |
|
212 |
public void createMissingFiles(String suffix) throws IOException |
|
213 |
{ |
|
214 |
System.out.println("Looking for missing messages files "+ suffix); |
|
215 |
for(File dirfile : dirfiles) { |
|
216 |
//println "DIRECTORY : "+dirfile |
|
217 |
File reference = null; |
|
218 |
String lookingname = ""; |
|
219 |
List<File> files = propertyfiles.get(dirfile); |
|
220 |
if (files.get(0).getName().startsWith("m")) { |
|
221 |
reference = new File(dirfile,"messages.properties"); |
|
222 |
lookingname = "messages_"+suffix+".properties"; |
|
223 |
} |
|
224 |
else if (files.get(0).getName().startsWith("b")) |
|
225 |
{ |
|
226 |
reference = new File(dirfile,"bundle.properties"); |
|
227 |
lookingname = "bundle_"+suffix+".properties"; |
|
228 |
} |
|
229 |
|
|
230 |
boolean create = true; |
|
231 |
if (reference != null && reference.exists()) { |
|
232 |
for(File f : files) |
|
233 |
{ |
|
234 |
if(f.getName() == lookingname) |
|
235 |
create = false; |
|
236 |
} |
|
237 |
} |
|
238 |
if (create) { |
|
239 |
new File(dirfile,lookingname).createNewFile(); |
|
240 |
System.out.println("Create file " +new File(dirfile,lookingname)); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
/* (non-Javadoc) |
|
246 |
* @see java.lang.Object#toString() |
|
247 |
*/ |
|
248 |
public String toString() { |
|
249 |
|
|
250 |
String rez = ""; |
|
251 |
for(File dirfile : dirfiles) { |
|
252 |
rez += dirfile+"\n"; |
|
253 |
for(File f : propertyfiles.get(dirfile)) |
|
254 |
rez += " "+f.getName()+"\n"; |
|
255 |
} |
|
256 |
return rez; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* Scan directory. |
|
261 |
* |
|
262 |
* @param directory the directory |
|
263 |
*/ |
|
264 |
public void scanDirectory(File directory) |
|
265 |
{ |
|
266 |
if (!directory.exists()) { |
|
267 |
System.out.println("directory '$directory' does not exists"); |
|
268 |
return; |
|
269 |
} |
|
270 |
|
|
271 |
System.out.println("scan directory : "+directory.getAbsolutePath()); |
|
272 |
LinkedList<File> files = new LinkedList<File>(); |
|
273 |
files.add(directory); |
|
274 |
|
|
275 |
while(!files.isEmpty()) { |
|
276 |
|
|
277 |
File current = files.removeFirst(); |
|
278 |
if (current.isDirectory()) { |
|
279 |
List<File> currentpfiles = new ArrayList<>(); |
|
280 |
for(File sfile : current.listFiles(IOUtils.HIDDENFILE_FILTER)) |
|
281 |
{ |
|
282 |
if(sfile.isDirectory()) { |
|
283 |
files.add(sfile); |
|
284 |
} else if(sfile.getName().endsWith(".properties") && ( sfile.getName().startsWith("messages") || sfile.getName().startsWith("bundle")) ) { |
|
285 |
currentpfiles.add(sfile); |
|
286 |
} |
|
287 |
} |
|
288 |
if (currentpfiles.size() > 0) { |
|
289 |
dirfiles.add(current); |
|
290 |
propertyfiles.put(current, currentpfiles); |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
/** |
|
297 |
* The main method. |
|
298 |
* |
|
299 |
* @param args the arguments |
|
300 |
* @throws IOException |
|
301 |
*/ |
|
302 |
public static void main(String[] args) throws IOException |
|
303 |
{ |
|
304 |
String userdir = System.getProperty("user.home"); |
|
305 |
|
|
306 |
System.out.println("\nRCP\n"); |
|
307 |
|
|
308 |
ExternalizationFilesUpdater scanner = new ExternalizationFilesUpdater(); |
|
309 |
// scanner.scanDirectory(new File(userdir, "workspace37/org.txm.rcp")); // find directories with a messages.properties file |
|
310 |
// scanner.createMissingFiles("fr"); // create messages_fr.properties files when a messages.properties is found |
|
311 |
// scanner.processFoundDirectories(); // find missing and obsolets keys |
|
312 |
// scanner.updateFiles(); // update messages files content |
|
313 |
|
|
314 |
System.out.println("\nTOOLBOX\n"); |
|
315 |
|
|
316 |
scanner = new ExternalizationFilesUpdater(); |
|
317 |
scanner.scanDirectory(new File(userdir, "workspace047/org.txm.rcp/src/main/java")); |
|
318 |
scanner.createMissingFiles("fr"); |
|
319 |
scanner.createMissingFiles("ru"); |
|
320 |
scanner.processFoundDirectories(); |
|
321 |
scanner.updateFiles(); |
|
322 |
} |
|
323 |
} |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/I18nDiff.groovy (revision 3447) | ||
---|---|---|
75 | 75 |
|
76 | 76 |
public static void main(String[] args) { |
77 | 77 |
String userhome = System.getProperty("user.home"); |
78 |
File f1 = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle.properties")
|
|
79 |
File f2 = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties")
|
|
78 |
File f1 = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle.properties")
|
|
79 |
File f2 = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties")
|
|
80 | 80 |
|
81 | 81 |
I18nDiff diff = new I18nDiff(f1, f2); |
82 | 82 |
diff.synchronizeFromF1toF2() |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/FindUntranslatedMessages.java (revision 3447) | ||
---|---|---|
1 |
package org.txm.rcp.translate.i18n; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.util.Arrays; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public class FindUntranslatedMessages { |
|
9 |
public static void main(String[] args) throws IOException { |
|
10 |
String userdir = System.getProperty("user.home"); |
|
11 |
File workspace = new File(userdir, "workspace047"); |
|
12 |
List<String> langs = Arrays.asList("fr", "ru"); |
|
13 |
|
|
14 |
ExternalizationFilesUpdater scanner = new ExternalizationFilesUpdater(); |
|
15 |
scanner.scanDirectory(new File(workspace, "org.txm.rcp")); |
|
16 |
for (String lang : langs) { |
|
17 |
scanner.createMissingFiles(lang); |
|
18 |
} |
|
19 |
scanner.processFoundDirectories(); |
|
20 |
scanner.updateFiles(); |
|
21 |
} |
|
22 |
} |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/IsStringUsedInPlugin.groovy (revision 3447) | ||
---|---|---|
52 | 52 |
|
53 | 53 |
public static void main(String[] args) { |
54 | 54 |
String userhome = System.getProperty("user.home") |
55 |
File propertyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle.properties");
|
|
56 |
File pluginFile = new File(userhome, "workspace43/org.txm.rcp/plugin.xml");
|
|
55 |
File propertyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle.properties");
|
|
56 |
File pluginFile = new File(userhome, "workspace047/org.txm.rcp/plugin.xml");
|
|
57 | 57 |
IsStringUsedInPlugin fixer = new IsStringUsedInPlugin(); |
58 | 58 |
//uncomment to remove unused Strings |
59 | 59 |
if (fixer.scan(propertyFile, pluginFile)) { |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/ExternalizerUI.groovy (revision 3447) | ||
---|---|---|
21 | 21 |
ExternalizeUI() { |
22 | 22 |
super(new FlowLayout()); |
23 | 23 |
File userDir = new File(System.getProperty("user.home")) |
24 |
File srcDir = new File(userDir, "workspace47/org.txm.rcp/src/main/java") |
|
25 |
File propFile = new File(srcDir, "org/txm/rcp/messages.properties") |
|
26 |
File messageFile = new File(srcDir, "org/txm/rcp/Messages.java") |
|
24 |
File srcDir = new File(userDir, "workspace047/org.txm.rcp/src/main/java")
|
|
25 |
File propFile = new File(srcDir, "org/txm/rcp/messages/messages.properties")
|
|
26 |
File messageFile = new File(srcDir, "org/txm/rcp/messages/TXMUIMessages.java")
|
|
27 | 27 |
|
28 | 28 |
println userDir |
29 | 29 |
println srcDir |
TXM/trunk/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/Merge2PropertiesFile.groovy (revision 3447) | ||
---|---|---|
1 | 1 |
package org.txm.rcp.translate.i18n |
2 | 2 |
|
3 |
File propFile1 = new File("/home/mdecorde/workspace43/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
4 |
File propFile2 = new File("/home/mdecorde/workspace43/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
3 |
File propFile1 = new File("/home/mdecorde/workspace047/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
4 |
File propFile2 = new File("/home/mdecorde/workspace047/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
5 | 5 |
|
6 | 6 |
Properties props1 = new Properties() |
7 | 7 |
props1.load(propFile1.newReader("iso-8859-1")) |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/setup/BuildFeatureFromProduct.groovy (revision 3447) | ||
---|---|---|
3 | 3 |
import groovy.xml.* |
4 | 4 |
|
5 | 5 |
String home = System.getProperty("user.home") |
6 |
File rcpSrc = new File(home, "workspace43/org.txm.rcp")
|
|
7 |
File rcpFeatureSrc = new File(home, "workspace43/org.txm.rcp.feature")
|
|
6 |
File rcpSrc = new File(home, "workspace047/org.txm.rcp")
|
|
7 |
File rcpFeatureSrc = new File(home, "workspace047/org.txm.rcp.feature")
|
|
8 | 8 |
File productFile = new File(rcpSrc, "rcp.product") |
9 | 9 |
File featureFile = new File(rcpFeatureSrc, "feature.xml") |
10 | 10 |
//File featureFileBackUp = new File(rcpFeatureSrc, "feature_back.xml") |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/IsStringMissingInPlugin.groovy (revision 3447) | ||
---|---|---|
10 | 10 |
|
11 | 11 |
public static void main(String[] args) { |
12 | 12 |
String userhome = System.getProperty("user.home") |
13 |
File propertyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties");
|
|
14 |
File copyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_copy.properties");
|
|
15 |
File pluginFile = new File(userhome, "workspace43/org.txm.rcp/plugin.xml");
|
|
13 |
File propertyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties");
|
|
14 |
File copyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_copy.properties");
|
|
15 |
File pluginFile = new File(userhome, "workspace047/org.txm.rcp/plugin.xml");
|
|
16 | 16 |
if (!(propertyFile.exists() && propertyFile.canRead() && propertyFile.canWrite() && propertyFile.isFile())) |
17 | 17 |
{ |
18 | 18 |
println "error file : "+propertyFile |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/ExternalizationFilesUpdater.groovy (revision 3447) | ||
---|---|---|
304 | 304 |
println "\nTOOLBOX\n"; |
305 | 305 |
|
306 | 306 |
scanner = new ExternalizationFilesUpdater(); |
307 |
scanner.scanDirectory(new File(userdir, "workspace43/org.txm.rcp/src/main/java"));
|
|
307 |
scanner.scanDirectory(new File(userdir, "workspace047/org.txm.rcp/src/main/java"));
|
|
308 | 308 |
scanner.createMissingFiles("fr"); |
309 | 309 |
scanner.createMissingFiles("ru"); |
310 | 310 |
scanner.processFoundDirectories(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/I18nDiff.groovy (revision 3447) | ||
---|---|---|
75 | 75 |
|
76 | 76 |
public static void main(String[] args) { |
77 | 77 |
String userhome = System.getProperty("user.home"); |
78 |
File f1 = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle.properties")
|
|
79 |
File f2 = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties")
|
|
78 |
File f1 = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle.properties")
|
|
79 |
File f2 = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties")
|
|
80 | 80 |
|
81 | 81 |
I18nDiff diff = new I18nDiff(f1, f2); |
82 | 82 |
diff.synchronizeFromF1toF2() |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/IsStringUsedInPlugin.groovy (revision 3447) | ||
---|---|---|
52 | 52 |
|
53 | 53 |
public static void main(String[] args) { |
54 | 54 |
String userhome = System.getProperty("user.home") |
55 |
File propertyFile = new File(userhome, "workspace43/org.txm.rcp/OSGI-INF/l10n/bundle.properties");
|
|
56 |
File pluginFile = new File(userhome, "workspace43/org.txm.rcp/plugin.xml");
|
|
55 |
File propertyFile = new File(userhome, "workspace047/org.txm.rcp/OSGI-INF/l10n/bundle.properties");
|
|
56 |
File pluginFile = new File(userhome, "workspace047/org.txm.rcp/plugin.xml");
|
|
57 | 57 |
IsStringUsedInPlugin fixer = new IsStringUsedInPlugin(); |
58 | 58 |
//uncomment to remove unused Strings |
59 | 59 |
if (fixer.scan(propertyFile, pluginFile)) { |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/ExternalizerUI.groovy (revision 3447) | ||
---|---|---|
21 | 21 |
ExternalizeUI() { |
22 | 22 |
super(new FlowLayout()); |
23 | 23 |
File userDir = new File(System.getProperty("user.home")) |
24 |
File srcDir = new File(userDir, "workspace47/org.txm.rcp/src/main/java") |
|
24 |
File srcDir = new File(userDir, "workspace047/org.txm.rcp/src/main/java")
|
|
25 | 25 |
File propFile = new File(srcDir, "org/txm/rcp/messages.properties") |
26 | 26 |
File messageFile = new File(srcDir, "org/txm/rcp/Messages.java") |
27 | 27 |
|
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/FindUntranslatedMessages.groovy (revision 3447) | ||
---|---|---|
3 | 3 |
import org.txm.scripts.scripts.i18n.ExternalizationFilesUpdater |
4 | 4 |
|
5 | 5 |
def userdir = System.getProperty("user.home") |
6 |
def workspace = new File(userdir, "workspace47") |
|
6 |
def workspace = new File(userdir, "workspace047")
|
|
7 | 7 |
def langs = ["fr", "ru"] |
8 | 8 |
|
9 | 9 |
scanner = new ExternalizationFilesUpdater(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/Merge2PropertiesFile.groovy (revision 3447) | ||
---|---|---|
1 | 1 |
package org.txm.scripts.scripts.i18n |
2 | 2 |
|
3 |
File propFile1 = new File("/home/mdecorde/workspace43/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
4 |
File propFile2 = new File("/home/mdecorde/workspace43/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
3 |
File propFile1 = new File("/home/mdecorde/workspace047/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
4 |
File propFile2 = new File("/home/mdecorde/workspace047/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties")
|
|
5 | 5 |
|
6 | 6 |
Properties props1 = new Properties() |
7 | 7 |
props1.load(propFile1.newReader("iso-8859-1")) |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/i18n/ReverseI18nDict.groovy (revision 3447) | ||
---|---|---|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
public static void main(String[] args) { |
117 |
File propFile = new File("/home/mdecorde/workspace43/org.txm.core/src/java/org/txm/messages.properties")
|
|
118 |
File messageFile = new File("/home/mdecorde/workspace43/org.txm.core/src/java/org/txm/Messages.java")
|
|
117 |
File propFile = new File("/home/mdecorde/workspace047/org.txm.core/src/java/org/txm/messages.properties")
|
|
118 |
File messageFile = new File("/home/mdecorde/workspace047/org.txm.core/src/java/org/txm/Messages.java")
|
|
119 | 119 |
ReverseI18nDict dict = new ReverseI18nDict(propFile, messageFile); |
120 | 120 |
println dict.getMissingsMessageKeys() |
121 | 121 |
println dict.getMissingPropKeys(); |
TXM/trunk/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties (revision 3447) | ||
---|---|---|
1 |
#/home/mdecorde/workspace43/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties + /home/mdecorde/workspace43/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties
|
|
1 |
#/home/mdecorde/workspace047/org.eclipse.equinox.p2.ui.nl_fr/org/eclipse/equinox/internal/p2/ui/messages_fr.properties + /home/mdecorde/workspace047/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages_fr.properties
|
|
2 | 2 |
#Tue Apr 15 11:45:28 CEST 2014 |
3 | 3 |
QueryableMetadataRepositoryManager_LoadRepositoryProgress=Prise de contact avec {0} |
4 | 4 |
RevertIUCommandTooltip=Revenir ? une pr?c?dente configuration install?e |
Formats disponibles : Unified diff