Revision 6129 trunk/libraries/libInternationalization/src-utils/org/gvsig/i18n/utils/TranslationDatabase.java
TranslationDatabase.java | ||
---|---|---|
32 | 32 |
String lang; |
33 | 33 |
Properties dictionary; |
34 | 34 |
|
35 |
File databaseDir = new File(config.databaseDir); |
|
36 | 35 |
FileInputStream stream=null; |
37 | 36 |
|
38 | 37 |
for (int currentLang=0; currentLang<config.languages.length; currentLang++) { |
39 | 38 |
lang = config.languages[currentLang]; |
40 | 39 |
dictionary = new Properties(); |
41 |
try { |
|
42 |
if (databaseDir.isAbsolute()) |
|
43 |
stream = new FileInputStream(config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
44 |
else |
|
45 |
stream = new FileInputStream(config.defaultBaseDir+File.separator+config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
40 |
try { |
|
41 |
stream = new FileInputStream(config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
46 | 42 |
try { |
47 | 43 |
dictionary.load(stream); |
48 | 44 |
} catch (IOException e) { |
... | ... | |
59 | 55 |
String lang; |
60 | 56 |
Properties dictionary; |
61 | 57 |
|
62 |
File databaseDir = new File(config.databaseDir); |
|
63 | 58 |
FileOutputStream stream=null; |
64 | 59 |
|
65 | 60 |
for (int currentLang=0; currentLang<config.languages.length; currentLang++) { |
... | ... | |
67 | 62 |
|
68 | 63 |
dictionary = ((Properties)dictionaries.get(lang)); |
69 | 64 |
|
70 |
try { |
|
71 |
if (databaseDir.isAbsolute()) |
|
72 |
stream = new FileOutputStream(config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
73 |
else |
|
74 |
stream = new FileOutputStream(config.defaultBaseDir+File.separator+config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
65 |
try { |
|
66 |
stream = new FileOutputStream(config.databaseDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
75 | 67 |
try { |
76 | 68 |
dictionary.store(stream, "Translations for language: " + lang); |
77 | 69 |
} catch (IOException e) { |
... | ... | |
165 | 157 |
Properties dictionary = (Properties) dictionaries.get(lang); |
166 | 158 |
return dictionary.containsValue(translation); |
167 | 159 |
} |
168 |
|
|
169 |
/*public void loadFromProjects() { |
|
170 |
String lang; |
|
171 |
ResourceBundle bundle; |
|
172 |
HashMap dictionary; |
|
173 |
|
|
174 |
Enumeration keys; |
|
175 |
String currentKey; |
|
176 |
|
|
177 |
String dir, basename; |
|
178 |
for (int currentLang=0; currentLang<config.languages.length; currentLang++) { |
|
179 |
lang = config.languages[currentLang]; |
|
180 |
dictionary = new HashMap(); |
|
181 |
for (int currentProject=0; currentProject<config.projects.size(); currentProject++) { |
|
182 |
dir = ((String[])config.projects.get(currentProject))[0]; // dir |
|
183 |
basename = ((String[])config.projects.get(currentProject))[1]; // basename |
|
184 |
|
|
185 |
// we need an url array to create the classloader |
|
186 |
URL[] urls = new URL[1]; |
|
187 |
try { |
|
188 |
urls[0] = (new File(dir)).toURL(); |
|
189 |
} catch (MalformedURLException e) { |
|
190 |
// TODO Auto-generated catch block |
|
191 |
e.printStackTrace(); |
|
192 |
} |
|
193 |
bundle = ResourceBundle.getBundle(basename, new Locale(lang), new MessagesClassLoader(urls)); |
|
194 |
keys = bundle.getKeys(); |
|
195 |
while (keys.hasMoreElements()) { |
|
196 |
currentKey = (String) keys.nextElement(); |
|
197 |
if (! ((HashMap)dictionary).containsKey(currentKey)) { |
|
198 |
((HashMap)dictionary).put(currentKey, bundle.getString(currentKey)); |
|
199 |
} |
|
200 |
else { |
|
201 |
if (bundle.getString(currentKey).equals((HashMap)dictionary.get(currentKey))) { |
|
202 |
System.err.println("Alerta: dos claves iguales con distinto mensaje:"); |
|
203 |
System.err.println(currentKey+"="+(HashMap)dictionary.get(currentKey)); |
|
204 |
System.err.println(currentKey+"="+bundle.getString(currentKey) + " -- Proyecto: "+dir); |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
dictionaries.put(lang, dictionary); |
|
210 |
} |
|
211 |
}*/ |
|
212 | 160 |
} |
Also available in: Unified diff