8 |
import java.util.Locale; |
import java.util.Locale; |
9 |
|
|
10 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
11 |
|
import javax.swing.JTable; |
12 |
|
|
13 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
14 |
|
|
58 |
/** |
/** |
59 |
* Set up the {@link Translation}-system to use language. If a change is |
* Set up the {@link Translation}-system to use language. If a change is |
60 |
* performed, events are fired to listeners. Nothing is done if the new |
* performed, events are fired to listeners. Nothing is done if the new |
61 |
* language equals the old language. |
* language equals the old language. The system's default locale is changed. |
62 |
* |
* |
63 |
* @param newLang |
* @param newLang |
64 |
* The ISO Code of the new active language |
* The ISO Code of the new active language |
65 |
*/ |
*/ |
66 |
public static void setActiveLang(String newLang) { |
public static void setActiveLang(String newLang) { |
67 |
|
setActiveLang(newLang, true); |
68 |
|
} |
69 |
|
|
70 |
|
/** |
71 |
|
* Set up the {@link Translation}-system to use language. If a change is |
72 |
|
* performed, events are fired to listeners. Nothing is done if the new |
73 |
|
* language equals the old language. |
74 |
|
* |
75 |
|
* @param newLang |
76 |
|
* The ISO Code of the new active language |
77 |
|
* |
78 |
|
* @param setDefaultLocale |
79 |
|
* Shall the system's default locale be changed? |
80 |
|
*/ |
81 |
|
public static void setActiveLang(String newLang, boolean setDefaultLocale) { |
82 |
if (getActiveLang().equals(newLang)) { |
if (getActiveLang().equals(newLang)) { |
83 |
return; |
return; |
84 |
} |
} |
89 |
} |
} |
90 |
|
|
91 |
Locale newLocale = new Locale(newLang); |
Locale newLocale = new Locale(newLang); |
92 |
Locale.setDefault(newLocale); |
if (setDefaultLocale) |
93 |
|
Locale.setDefault(newLocale); |
94 |
|
|
95 |
/** |
/** |
96 |
* Setting default locale for Swing JComponents to work around bug |
* Setting default locale for Swing JComponents to work around bug |
106 |
} |
} |
107 |
|
|
108 |
/** |
/** |
109 |
* Initializes a new {@link Translation} with a default translation. Other |
* Initializes a new {@link Translation} with a default translation if a |
110 |
* translations may be added later. |
* simple text is passed. If a "oneLine" text is parsed, it is interpreted. |
111 |
|
* Other translations may be added later - this is a HashMap<br/> |
112 |
* |
* |
113 |
* @param defaultTranslation |
* @param defaultTranslation |
114 |
* |
* |
|
* @deprecated SK: The concept of the default translation doesn't seem so |
|
|
* nice to me anymore.. I would prefer the default translation |
|
|
* to be set for all valid languages. |
|
|
* |
|
115 |
* @see public Translation(List<String> languages, String |
* @see public Translation(List<String> languages, String |
116 |
* defaultTranslation) { |
* defaultTranslation) { |
117 |
* |
* |
118 |
*/ |
*/ |
119 |
public Translation(String defaultTranslation) { |
public Translation(String defaultTranslation) { |
120 |
put(DEFAULT_KEY, defaultTranslation); |
|
121 |
|
fromOneLine(defaultTranslation); |
122 |
|
|
123 |
} |
} |
124 |
|
|
125 |
/** |
/** |
190 |
* @author Stefan Alfons Krüger |
* @author Stefan Alfons Krüger |
191 |
*/ |
*/ |
192 |
public String toOneLine() { |
public String toOneLine() { |
193 |
StringBuffer oneLine = new StringBuffer(); |
return I8NUtil.toOneLine(this); |
|
for (String key : keySet()) { |
|
|
oneLine.append(key + "{" + get(key) + "}"); |
|
|
} |
|
|
return oneLine.toString(); |
|
194 |
} |
} |
195 |
|
|
196 |
/** |
/** |
218 |
// MS: |
// MS: |
219 |
else { |
else { |
220 |
if (get(DEFAULT_KEY) != null) { |
if (get(DEFAULT_KEY) != null) { |
221 |
// log.debug("default lng returned, cuz the translation to "+activeLang+" was not found. Schmeiss raus martin, wenn du das mit der default trans geklärt hast."); |
// log.debug("default lang returned, cuz the translation to "+activeLang+" was not found. Schmeiss raus martin, wenn du das mit der default trans geklärt hast."); |
222 |
return get(DEFAULT_KEY); |
return get(DEFAULT_KEY); |
223 |
} |
} |
224 |
|
|
274 |
} |
} |
275 |
} |
} |
276 |
|
|
|
|
|
277 |
} |
} |