1 package be
.nikiroo
.fanfix
.bundles
;
4 import java
.io
.IOException
;
5 import java
.util
.Locale
;
7 import be
.nikiroo
.utils
.resources
.TransBundle
;
10 * This class manages the translation resources of the application.
14 public class StringIdBundle
extends TransBundle
<StringId
> {
18 * Create a translation service for the given language (will fall back to
19 * the default one i not found).
24 public StringIdBundle(String lang
) {
25 super(StringId
.class, Target
.resources
, lang
);
30 * Return the currently used language as a String.
32 * @return the language
34 * @deprecated use the call from {@link TransBundle} when available
36 public Locale
getLanguage() {
37 return getLocaleFor(lang
);
42 * Update resource file.
48 * in case of I/O error
50 public static void main(String
[] args
) throws IOException
{
51 String path
= new File(".").getAbsolutePath()
52 + "/src/be/nikiroo/fanfix/bundles/";
53 new StringIdBundle(null).updateFile(path
);
54 System
.out
.println("Path updated: " + path
);
58 * Return the {@link Locale} representing the given language.
61 * the language to initialise, in the form "en-GB" or "fr" for
64 * @return the corresponding {@link Locale} or the default {@link Locale} if
67 * @deprecated Use the call from {@link TransBundle} when available.
69 static private Locale
getLocaleFor(String language
) {
72 if (language
== null) {
73 locale
= Locale
.getDefault();
75 language
= language
.replaceAll("_", "-");
76 String lang
= language
;
77 String country
= null;
78 if (language
.contains("-")) {
79 lang
= language
.split("-")[0];
80 country
= language
.split("-")[1];
84 locale
= new Locale(lang
, country
);
86 locale
= new Locale(lang
);