1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.i18n;
17
18 import java.util.Locale;
19 import java.util.ResourceBundle;
20
21 import org.apache.juddi.registry.RegistryEngine;
22 import org.apache.juddi.util.Config;
23
24 /***
25 * @author Steve Viens (sviens@apache.org)
26 */
27 public class RegistryResourceBundle
28 {
29 private static final String BASE_MESSAGE_BUNDLE = "org.apache.juddi.i18n.MessagesBundle";
30
31 private static ResourceBundle bundle = null;
32
33 public static String getString(String key)
34 {
35 if ((key == null) || (key.trim().length() == 0))
36 return null;
37 return getBundle().getString(key);
38 }
39
40 private static ResourceBundle getBundle()
41 {
42 if (bundle == null)
43 bundle = createBundle();
44 return bundle;
45 }
46
47 private static synchronized ResourceBundle createBundle()
48 {
49 if (bundle != null)
50 return bundle;
51
52 String language = Config.getStringProperty(RegistryEngine.PROPNAME_I18N_LANGUAGE_CODE);
53 if ((language == null) || (language.trim().length() == 0))
54 language = RegistryEngine.DEFAULT_I18N_LANGUAGE_CODE;
55
56 String country = Config.getStringProperty(RegistryEngine.PROPNAME_I18N_COUNTRY_CODE);
57 if ((country == null) || (country.trim().length() == 0))
58 country = RegistryEngine.DEFAULT_I18N_COUNTRY_CODE;
59
60 bundle = ResourceBundle.getBundle(
61 BASE_MESSAGE_BUNDLE,
62 new Locale(language,country));
63
64 return bundle;
65 }
66
67
68 /****************************************************************************/
69 /****************************** TEST DRIVER *********************************/
70 /****************************************************************************/
71
72
73 public static void main(String[] args)
74 {
75 System.out.println(RegistryResourceBundle.getString("E_authTokenRequired"));
76 }
77 }