-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathResourceBundleEx.java
More file actions
41 lines (26 loc) · 834 Bytes
/
ResourceBundleEx.java
File metadata and controls
41 lines (26 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.zetcode;
import java.util.Locale;
import java.util.ResourceBundle;
public class ResourceBundleEx {
static public void main(String[] args) {
Locale[] locales = {
Locale.GERMAN,
new Locale("sk", "SK"),
Locale.ENGLISH
};
System.out.println("w1:");
for (Locale locale : locales) {
getWord(locale, "w1");
}
System.out.println("w2:");
for (Locale locale : locales) {
getWord(locale, "w2");
}
}
static void getWord(Locale curLoc, String key) {
ResourceBundle words
= ResourceBundle.getBundle("resources/words", curLoc);
String value = words.getString(key);
System.out.printf("Locale: %s, Value: %s %n", curLoc.toString(), value);
}
}