4 |
import java.util.Set; |
import java.util.Set; |
5 |
import java.util.TreeSet; |
import java.util.TreeSet; |
6 |
|
|
7 |
|
import org.apache.log4j.Logger; |
8 |
|
|
9 |
public class I8NUtil { |
public class I8NUtil { |
10 |
|
static final Logger LOGGER = Logger.getLogger(I8NUtil.class); |
11 |
|
|
12 |
private static Set<String> languageCodes = new TreeSet<String>(); |
private static Set<String> languageCodes = new TreeSet<String>(); |
13 |
static { |
static { |
19 |
// } |
// } |
20 |
} |
} |
21 |
|
|
|
// |
|
|
// /** |
|
|
// * @Returns an ImageIcon for a given ISO code or null. |
|
|
// * @param code ISO Country Code |
|
|
// */ |
|
|
// public static ImageIcon getFlagIcon(String code) { |
|
|
// |
|
|
// String ressourcename = "resource/flags/" + code.toUpperCase() + ".gif"; |
|
|
// |
|
|
// URL resourceURL = TranslationEditJPanel.class.getResource(ressourcename); |
|
|
// |
|
|
// if (resourceURL != null) |
|
|
// return new ImageIcon( resourceURL); |
|
|
// |
|
|
// return new ImageIcon(); |
|
|
// } |
|
|
// |
|
|
// /** |
|
|
// * @Returns an {@link ImageIcon} flag for the language setup as |
|
|
// Translation language |
|
|
// */ |
|
|
// public static ImageIcon getFlagIcon() { |
|
|
// return getFlagIcon( Translation.getActiveLang() ); |
|
|
// } |
|
|
|
|
22 |
/** |
/** |
23 |
* @author Stefan Alfons Krüger |
* @author Stefan Alfons Krüger |
24 |
* @param code |
* @param code |
44 |
*/ |
*/ |
45 |
public static Locale getLocaleFor(String code) { |
public static Locale getLocaleFor(String code) { |
46 |
for (Locale l : Locale.getAvailableLocales()) { |
for (Locale l : Locale.getAvailableLocales()) { |
47 |
System.out.println(l.getLanguage()+" not = "+code); |
// System.out.println(l.getLanguage()+" not = "+code); |
48 |
if (l.getLanguage().toLowerCase().equals(code.toLowerCase())) { |
if (l.getLanguage().toLowerCase().equals(code.toLowerCase())) { |
49 |
return l; |
return l; |
50 |
} |
} |
51 |
} |
} |
52 |
return null; |
LOGGER.error("Can't create a Locale for code "+code+"! Returning the system default locale to avoid NPEs."); |
53 |
|
return Locale.getDefault(); |
54 |
} |
} |
55 |
} |
} |