Revision 26324 branches/v10/extensions/extI18n/src/org/gvsig/i18n/impl/I18nManagerImpl.java
I18nManagerImpl.java | ||
---|---|---|
27 | 27 |
package org.gvsig.i18n.impl; |
28 | 28 |
|
29 | 29 |
import java.io.*; |
30 |
import java.security.AccessController; |
|
30 | 31 |
import java.util.*; |
31 | 32 |
import java.util.Map.Entry; |
32 | 33 |
import java.util.jar.*; |
... | ... | |
34 | 35 |
|
35 | 36 |
import org.gvsig.i18n.*; |
36 | 37 |
|
38 |
import sun.security.action.GetPropertyAction; |
|
39 |
|
|
37 | 40 |
import com.iver.andami.Launcher; |
38 | 41 |
import com.iver.andami.PluginServices; |
39 | 42 |
import com.iver.andami.config.generate.AndamiConfig; |
... | ... | |
239 | 242 |
public Locale getCurrentLocale() { |
240 | 243 |
return Locale.getDefault(); |
241 | 244 |
} |
245 |
|
|
246 |
public Locale getDefaultSystemLocale() { |
|
247 |
String language, region, country, variant; |
|
248 |
language = (String) AccessController |
|
249 |
.doPrivileged(new GetPropertyAction("user.language", "en")); |
|
250 |
// for compatibility, check for old user.region property |
|
251 |
region = (String) AccessController.doPrivileged(new GetPropertyAction( |
|
252 |
"user.region")); |
|
253 |
if (region != null) { |
|
254 |
// region can be of form country, country_variant, or _variant |
|
255 |
int i = region.indexOf('_'); |
|
256 |
if (i >= 0) { |
|
257 |
country = region.substring(0, i); |
|
258 |
variant = region.substring(i + 1); |
|
259 |
} |
|
260 |
else { |
|
261 |
country = region; |
|
262 |
variant = ""; |
|
263 |
} |
|
264 |
} |
|
265 |
else { |
|
266 |
country = (String) AccessController |
|
267 |
.doPrivileged(new GetPropertyAction("user.country", "")); |
|
268 |
variant = (String) AccessController |
|
269 |
.doPrivileged(new GetPropertyAction("user.variant", "")); |
|
270 |
} |
|
271 |
return new Locale(language, country, variant); |
|
272 |
} |
|
242 | 273 |
|
243 | 274 |
public void setCurrentLocale(Locale locale) { |
244 | 275 |
AndamiConfig config = Launcher.getAndamiConfig(); |
... | ... | |
272 | 303 |
importLocales.add(locale); |
273 | 304 |
|
274 | 305 |
// Add the locale to the list of installed ones, if it |
275 |
// is |
|
276 |
// new, otherwise, update the texts. |
|
306 |
// is new, otherwise, update the texts. |
|
277 | 307 |
if (!registeredLocales.contains(locale)) { |
278 | 308 |
registeredLocales.add(locale); |
279 | 309 |
storeInstalledLocales(); |
... | ... | |
295 | 325 |
} |
296 | 326 |
} |
297 | 327 |
|
328 |
jaris.close(); |
|
329 |
fis.close(); |
|
298 | 330 |
} catch (Exception ex) { |
299 | 331 |
throw new InstallLocalesException(importFile, ex); |
300 | 332 |
} |
... | ... | |
430 | 462 |
return Messages.getAllTexts(locale); |
431 | 463 |
} |
432 | 464 |
|
465 |
// private Map getZipFileLocales(ZipFile zipFile) throws IOException { |
|
466 |
// ZipEntry zipEntry = zipFile.getEntry("locales.csv"); |
|
467 |
// |
|
468 |
// if (zipEntry == null) { |
|
469 |
// return null; |
|
470 |
// } |
|
471 |
// |
|
472 |
// InputStream is = zipFile.getInputStream(zipEntry); |
|
473 |
// BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
|
474 |
// |
|
475 |
// Map locales = new HashMap(4); |
|
476 |
// String line; |
|
477 |
// while ((line = reader.readLine()) != null) { |
|
478 |
// StringTokenizer st = new StringTokenizer(line, ","); |
|
479 |
// String language = st.nextToken(); |
|
480 |
// String country = st.nextToken(); |
|
481 |
// country = country == null ? "" : country; |
|
482 |
// String variant = st.nextToken(); |
|
483 |
// variant = variant == null ? "" : variant; |
|
484 |
// String ref = st.nextToken(); |
|
485 |
// |
|
486 |
// Locale locale = new Locale(language, country, variant); |
|
487 |
// |
|
488 |
// } |
|
489 |
// } |
|
490 |
|
|
433 | 491 |
/** |
434 | 492 |
* Returns if a locale is one of the default reference ones. |
435 | 493 |
*/ |
Also available in: Unified diff