Révision 1236
| tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/FindMessagesToBind.java (revision 1236) | ||
|---|---|---|
| 1 | 1 |
package org.txm.rcp.translate.devtools; |
| 2 | 2 |
|
| 3 |
import java.io.BufferedReader; |
|
| 4 | 3 |
import java.io.File; |
| 5 | 4 |
import java.io.FileNotFoundException; |
| 6 | 5 |
import java.io.IOException; |
| 7 | 6 |
import java.io.UnsupportedEncodingException; |
| 8 | 7 |
import java.util.ArrayList; |
| 9 | 8 |
import java.util.LinkedHashMap; |
| 9 |
import java.util.regex.Matcher; |
|
| 10 |
import java.util.regex.Pattern; |
|
| 10 | 11 |
|
| 11 | 12 |
import org.txm.rcp.translate.i18n.PluginMessages; |
| 12 | 13 |
import org.txm.rcp.translate.i18n.WorkspaceMessagesManager; |
| ... | ... | |
| 27 | 28 |
//String line = reader.readLine(); |
| 28 | 29 |
boolean ignore = false; |
| 29 | 30 |
ArrayList<String> lines = IOUtils.getLines(sourceFile, "UTF-8"); |
| 31 |
ArrayList<String> toBind = new ArrayList<String>(); |
|
| 30 | 32 |
|
| 33 |
int n = 0; |
|
| 31 | 34 |
for (String line : lines) {
|
| 35 |
n++; |
|
| 32 | 36 |
//println ""+line |
| 33 | 37 |
String l = line.trim(); |
| 34 | 38 |
|
| ... | ... | |
| 43 | 47 |
ignore = true; |
| 44 | 48 |
if (l.endsWith("*/")) ignore=false;
|
| 45 | 49 |
} else {
|
| 46 |
ArrayList<String> strings = getLineStrings(l); |
|
| 47 |
if (strings.size() > 0) {
|
|
| 48 |
System.out.println(strings); |
|
| 50 |
// ArrayList<String> strings = getLineStrings(l); |
|
| 51 |
// if (strings.size() > 0) {
|
|
| 52 |
// System.out.println(strings); |
|
| 53 |
// } |
|
| 54 |
|
|
| 55 |
Matcher m = p1.matcher(l); |
|
| 56 |
if (m.find()) {
|
|
| 57 |
toBind.add(""+n+"\t"+l);
|
|
| 58 |
// System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
|
| 59 |
//System.out.println("1 "+m.group(1));
|
|
| 60 |
} else {
|
|
| 61 |
m = p2.matcher(l); |
|
| 62 |
if (m.find()) {
|
|
| 63 |
toBind.add(""+n+"\t"+l);
|
|
| 64 |
// System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
|
| 65 |
//System.out.println("2 "+m.group(2));
|
|
| 66 |
} else if (!l.contains("$NON-NLS-")) {
|
|
| 67 |
m = p3.matcher(l); |
|
| 68 |
if (m.find()) {
|
|
| 69 |
toBind.add(""+n+"\t"+l);
|
|
| 70 |
//System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
|
| 71 |
//System.out.println("2 "+m.group(2));
|
|
| 72 |
} else {
|
|
| 73 |
|
|
| 74 |
} |
|
| 75 |
} |
|
| 49 | 76 |
} |
| 50 | 77 |
} |
| 51 | 78 |
} |
| 52 |
|
|
| 53 | 79 |
} |
| 80 |
|
|
| 81 |
if (toBind.size() > 0) {
|
|
| 82 |
System.out.println(sourceFile.getAbsolutePath()); |
|
| 83 |
for (String l : toBind) {
|
|
| 84 |
System.out.println("\t"+l);
|
|
| 85 |
} |
|
| 86 |
} |
|
| 54 | 87 |
} |
| 55 |
|
|
| 88 |
Pattern p1 = Pattern.compile("([A-Z][a-zA-Z0-9]+Messages.[A-Z][a-zA-Z0-9_]+)( ?\\+)");
|
|
| 89 |
Pattern p2 = Pattern.compile("( ?\\\\+)([A-Z][a-zA-Z0-9]+Messages.[A-Z][a-zA-Z0-9_]+)");
|
|
| 90 |
Pattern p3 = Pattern.compile("(\"[^\"]+\" ?\\+)");
|
|
| 91 |
|
|
| 56 | 92 |
private ArrayList<String> getLineStrings(String l) {
|
| 57 | 93 |
ArrayList<String> strings = new ArrayList<String>(); |
| 58 | 94 |
boolean inS = false; |
| ... | ... | |
| 90 | 126 |
|
| 91 | 127 |
for (File project : h.keySet()) {
|
| 92 | 128 |
|
| 93 |
System.out.println("Project: "+project);
|
|
| 129 |
//System.out.println("Project: "+project);
|
|
| 94 | 130 |
|
| 95 | 131 |
File srcDir = new File(project, "src/java"); |
| 96 | 132 |
if (!srcDir.exists()) srcDir = new File(project, "src"); |
| ... | ... | |
| 102 | 138 |
if (!javaFile.getName().endsWith(".java")) continue;
|
| 103 | 139 |
if (javaFile.getName().endsWith("Messages.java")) continue;
|
| 104 | 140 |
|
| 105 |
System.out.println(" File: "+javaFile);
|
|
| 141 |
//System.out.println(" File: "+javaFile);
|
|
| 106 | 142 |
processSourceFile(javaFile); |
| 107 | 143 |
} |
| 108 | 144 |
} |
| tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java (revision 1236) | ||
|---|---|---|
| 323 | 323 |
System.out.println("findUnusedKeys: key " + unusedKeys.get(i) + " is unused in project " + dict.getProjectDirectory() + " (main language value = " + dict.getMessagesForLang("").get(unusedKeys.get(i)) + ")");
|
| 324 | 324 |
} |
| 325 | 325 |
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 | 326 |
//dict.summary(); |
| 330 | 327 |
//dict.saveChanges(); |
| 331 | 328 |
|
| tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/ExportTranslateProject.java (revision 1236) | ||
|---|---|---|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
String path = Toolbox.getTxmHomePath()+"/translate.zip"; |
| 36 |
ArrayList<IFile> propertiesFiles = new ArrayList<IFile>();
|
|
| 36 |
ArrayList<IResource> propertiesFiles = new ArrayList<IResource>();
|
|
| 37 | 37 |
try {
|
| 38 | 38 |
findPropertiesFile(newProject.getFolder("plugins"), propertiesFiles);
|
| 39 | 39 |
} catch (CoreException e1) {
|
| ... | ... | |
| 56 | 56 |
return null; |
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 |
public static ArrayList<IFile> findPropertiesFile(IResource r, ArrayList<IFile> propertiesFiles) throws CoreException {
|
|
| 59 |
public static ArrayList<IResource> findPropertiesFile(IResource r, ArrayList<IResource> propertiesFiles) throws CoreException {
|
|
| 60 | 60 |
if (r instanceof IFolder) {
|
| 61 | 61 |
IFolder dir = (IFolder)r; |
| 62 | 62 |
|
| tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/CreateTranslateProject.java (revision 1236) | ||
|---|---|---|
| 59 | 59 |
a.run(); |
| 60 | 60 |
|
| 61 | 61 |
// show only the properties files |
| 62 |
ArrayList<IFile> propertiesFiles = new ArrayList<>();
|
|
| 62 |
ArrayList<IResource> propertiesFiles = new ArrayList<>();
|
|
| 63 | 63 |
ExportTranslateProject.findPropertiesFile(plugins, propertiesFiles); |
| 64 | 64 |
IResource[] elements = propertiesFiles.toArray(new IResource[propertiesFiles.size()]); |
| 65 | 65 |
|
| ... | ... | |
| 120 | 120 |
srcFolder.createLink(path, IResource.ALLOW_MISSING_LOCAL, cpb); |
| 121 | 121 |
|
| 122 | 122 |
// set the encoding bundle=iso-8859-1, messages=utf-8 |
| 123 |
ArrayList<IFile> propertiesFiles = new ArrayList<IFile>();
|
|
| 123 |
ArrayList<IResource> propertiesFiles = new ArrayList<IResource>();
|
|
| 124 | 124 |
ExportTranslateProject.findPropertiesFile(srcFolder, propertiesFiles); |
| 125 | 125 |
for (IResource e : propertiesFiles) {
|
| 126 | 126 |
IFile f = (IFile)e; |
Formats disponibles : Unified diff