1 |
alfonx |
780 |
package skrueger.i8n; |
2 |
|
|
/******************************************************************************* |
3 |
alfonx |
895 |
* Copyright (c) 2010 Stefan A. Tzeggai. |
4 |
alfonx |
780 |
* All rights reserved. This program and the accompanying materials |
5 |
|
|
* are made available under the terms of the GNU Public License v2.0 |
6 |
|
|
* which accompanies this distribution, and is available at |
7 |
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
8 |
|
|
* |
9 |
|
|
* Contributors: |
10 |
alfonx |
895 |
* Stefan A. Tzeggai - initial API and implementation |
11 |
alfonx |
780 |
******************************************************************************/ |
12 |
|
|
import java.io.BufferedReader; |
13 |
|
|
import java.io.File; |
14 |
|
|
import java.io.FileReader; |
15 |
|
|
import java.io.IOException; |
16 |
alfonx |
893 |
import java.net.URISyntaxException; |
17 |
alfonx |
780 |
import java.util.HashMap; |
18 |
alfonx |
893 |
import java.util.Locale; |
19 |
alfonx |
780 |
|
20 |
alfonx |
893 |
import schmitzm.lang.ResourceProvider; |
21 |
alfonx |
780 |
|
22 |
alfonx |
893 |
|
23 |
alfonx |
780 |
/** |
24 |
alfonx |
893 |
* This tool helps to find missing french translations |
25 |
alfonx |
780 |
* |
26 |
|
|
*/ |
27 |
|
|
public class TranslationTool { |
28 |
|
|
|
29 |
alfonx |
893 |
static File GPenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/GeopublisherTranslation.properties"); |
30 |
|
|
static File GPfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/GeopublisherTranslation_fr.properties"); |
31 |
alfonx |
780 |
|
32 |
|
|
static File ASenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation.properties"); |
33 |
alfonx |
893 |
static File ASfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation_fr.properties"); |
34 |
alfonx |
780 |
|
35 |
|
|
static File AVenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation.properties"); |
36 |
alfonx |
893 |
static File AVfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation_fr.properties"); |
37 |
alfonx |
780 |
|
38 |
alfonx |
893 |
private static HashMap<String,String> frenchTranslations = new HashMap<String, String>(); |
39 |
alfonx |
780 |
|
40 |
|
|
/** |
41 |
|
|
* @param args |
42 |
|
|
* @throws IOException |
43 |
alfonx |
893 |
* @throws URISyntaxException |
44 |
alfonx |
780 |
*/ |
45 |
alfonx |
893 |
public static void main(String[] args) throws IOException, URISyntaxException { |
46 |
alfonx |
780 |
|
47 |
alfonx |
893 |
Locale dl = Locale.getDefault(); |
48 |
alfonx |
780 |
|
49 |
alfonx |
893 |
for (ResourceProvider p : ResourceProvider.getRegisteredResourceProvider()){ |
50 |
|
|
|
51 |
|
|
for (Locale l : p.getAvailableLocales(false)) { |
52 |
|
|
File propertyFile = ResourceProvider.getPropertyFile(p, l, null); |
53 |
|
|
} |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
|
57 |
alfonx |
780 |
BufferedReader en_Reader; |
58 |
|
|
BufferedReader fr_Reader; |
59 |
|
|
|
60 |
|
|
int mode = 3; |
61 |
|
|
|
62 |
|
|
if (mode == 1) { |
63 |
|
|
en_Reader = new BufferedReader(new FileReader(GPenglish)); |
64 |
alfonx |
893 |
fr_Reader = new BufferedReader(new FileReader(GPfrench)); |
65 |
alfonx |
780 |
} else if (mode == 2) { |
66 |
|
|
en_Reader = new BufferedReader(new FileReader(ASenglish)); |
67 |
alfonx |
893 |
fr_Reader = new BufferedReader(new FileReader(ASfrench)); |
68 |
alfonx |
780 |
} else { |
69 |
|
|
en_Reader = new BufferedReader(new FileReader(AVenglish)); |
70 |
alfonx |
893 |
fr_Reader = new BufferedReader(new FileReader(AVfrench)); |
71 |
alfonx |
780 |
} |
72 |
|
|
|
73 |
|
|
|
74 |
alfonx |
893 |
// Read all french translations keys into a HashMap |
75 |
alfonx |
780 |
String readLine = "start"; |
76 |
|
|
while (readLine != null) { |
77 |
|
|
readLine = fr_Reader.readLine(); |
78 |
|
|
if (readLine != null && !readLine.startsWith("#")) { |
79 |
|
|
int indexOf = readLine.indexOf("="); |
80 |
|
|
if (indexOf == -1) continue; |
81 |
|
|
String key = readLine.substring(0,indexOf).trim(); |
82 |
|
|
String value = readLine.substring(indexOf+1).trim(); |
83 |
alfonx |
893 |
frenchTranslations .put(key.trim(),value.trim()); |
84 |
alfonx |
780 |
} |
85 |
|
|
} |
86 |
|
|
|
87 |
alfonx |
893 |
System.out.println(frenchTranslations.size()+" french imported"); |
88 |
alfonx |
780 |
|
89 |
|
|
readLine = "start"; |
90 |
|
|
int missing =0; |
91 |
|
|
while (readLine != null) { |
92 |
|
|
readLine = en_Reader.readLine(); |
93 |
|
|
|
94 |
|
|
if (readLine != null && !readLine.startsWith("#")) { |
95 |
|
|
int indexOf = readLine.indexOf("="); |
96 |
|
|
if (indexOf == -1) continue; |
97 |
|
|
String key = readLine.substring(0,indexOf).trim(); |
98 |
|
|
String value = readLine.substring(indexOf+1).trim(); |
99 |
alfonx |
893 |
if (!frenchTranslations.containsKey(key)) { |
100 |
alfonx |
780 |
System.out.println("#"+key+"="+value+"\n"); |
101 |
|
|
missing++; |
102 |
|
|
} |
103 |
|
|
} |
104 |
|
|
} |
105 |
|
|
System.out.println("missing = "+missing); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
} |