The Java Program: Main.java
1 import java.text.MessageFormat;
2 import java.util.Locale;
3 import java.util.ResourceBundle;
4
5 public class Main {
6
7 final static Locale[] locArray = {
8 Locale.ENGLISH,Locale.FRENCH,Locale.GERMAN,Locale.KOREAN,new Locale("sv","")};
9
10 public static void main (String[] args) {
11
12 for (int i = 0; i < locArray.length; i++) {
13
14 final Locale loc = locArray[i];
15 System.out.println ("Using locale: " +loc);
16
17
18 final ResourceBundle myResources = ResourceBundle.getBundle("MyResources", loc);
19
20
21 final MessageFormat mf = new MessageFormat ("");
22 mf.setLocale(loc);
23
24
25 mf.applyPattern (myResources.getString("pattern"));
26
27
28 final Object[] arguments = {
29 new Integer(7),
30 new Long(System.currentTimeMillis()),
31 myResources.getString("color"),
32 myResources.getString("animal"),
33 };
34
35
36 System.out.println (mf.toPattern());
37
38
39 final String result = mf.format (arguments);
40
41
42 System.out.println (result);
43 System.out.println ();
44 }
45 }
46 }