1 |
mojays |
2 |
package skrueger.i8n; |
2 |
|
|
|
3 |
alfonx |
38 |
import java.util.Set; |
4 |
|
|
import java.util.TreeSet; |
5 |
mojays |
2 |
|
6 |
|
|
public class I8NUtil { |
7 |
|
|
|
8 |
alfonx |
38 |
private static Set<String> languageCodes = new TreeSet<String>(); |
9 |
mojays |
2 |
static { |
10 |
|
|
for (String code : java.util.Locale.getISOLanguages()) { |
11 |
alfonx |
38 |
getLanguageCodes().add(code); |
12 |
mojays |
2 |
} |
13 |
|
|
} |
14 |
|
|
// |
15 |
|
|
// /** |
16 |
|
|
// * @Returns an ImageIcon for a given ISO code or null. |
17 |
|
|
// * @param code ISO Country Code |
18 |
|
|
// */ |
19 |
|
|
// public static ImageIcon getFlagIcon(String code) { |
20 |
|
|
// |
21 |
|
|
// String ressourcename = "resource/flags/" + code.toUpperCase() + ".gif"; |
22 |
|
|
// |
23 |
|
|
// URL resourceURL = TranslationEditJPanel.class.getResource(ressourcename); |
24 |
|
|
// |
25 |
|
|
// if (resourceURL != null) |
26 |
|
|
// return new ImageIcon( resourceURL); |
27 |
|
|
// |
28 |
|
|
// return new ImageIcon(); |
29 |
|
|
// } |
30 |
|
|
// |
31 |
|
|
// /** |
32 |
|
|
// * @Returns an {@link ImageIcon} flag for the language setup as Translation language |
33 |
|
|
// */ |
34 |
|
|
// public static ImageIcon getFlagIcon() { |
35 |
|
|
// return getFlagIcon( Translation.getActiveLang() ); |
36 |
|
|
// } |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* @author Stefan Alfons Krüger |
41 |
|
|
* @param code |
42 |
|
|
* @return true if the code paramter is a valid ISO Language code |
43 |
|
|
*/ |
44 |
|
|
public static boolean isValidISOLangCode(String code) { |
45 |
alfonx |
38 |
return getLanguageCodes().contains(code); |
46 |
mojays |
2 |
} |
47 |
alfonx |
38 |
|
48 |
|
|
|
49 |
|
|
/** |
50 |
|
|
* @return All language codes available in java.util.Locale.getISOLanguages() without duplicates. |
51 |
|
|
*/ |
52 |
|
|
public static Set<String> getLanguageCodes() { |
53 |
|
|
return languageCodes; |
54 |
|
|
} |
55 |
mojays |
2 |
} |
56 |
|
|
|