1 package be
.nikiroo
.jvcard
.resources
;
3 import java
.util
.Locale
;
4 import java
.util
.ResourceBundle
;
7 * This class help you get UTF-8 bundles for this application.
12 public class Bundles
{
13 static private String confDir
= getConfDir();
16 * Return the non-localised bundle of the given name.
19 * the name of the bundle to load
23 static public ResourceBundle
getBundle(String name
) {
24 return ResourceBundle
.getBundle(Bundles
.class.getPackage().getName()
25 + "." + name
, new FixedResourceBundleControl(confDir
));
29 * Return the localised bundle of the given name and {@link Locale}.
32 * the name of the bundle to load
34 * the {@link Locale} to use
36 * @return the localised bundle
38 static public ResourceBundle
getBundle(String name
, Locale locale
) {
39 return ResourceBundle
.getBundle(Bundles
.class.getPackage().getName()
40 + "." + name
, locale
, new FixedResourceBundleControl(confDir
));
44 * Set the primary configuration directory to look for <tt>.properties</tt>
47 * All {@link ResourceBundle}s returned by this class after that point will
48 * respect this new directory.
53 static public void setDirectory(String confDir
) {
54 Bundles
.confDir
= confDir
;
58 * Return the configuration directory where to try to find the
59 * <tt>.properties</tt> files in priority.
61 * @return the configuration directory
63 static private String
getConfDir() {
64 // Do not override user-supplied config directory (see --help)
65 if (Bundles
.confDir
!= null)
66 return Bundles
.confDir
;
69 ResourceBundle bundle
= ResourceBundle
.getBundle(Bundles
.class
70 .getPackage().getName() + "." + "jvcard",
71 Locale
.getDefault(), new FixedResourceBundleControl(null));
73 String configDir
= bundle
.getString("CONFIG_DIR");
74 if (configDir
!= null && configDir
.trim().length() > 0)
76 } catch (Exception e
) {