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();
15 // TODO: rename to bundle, use it as base for i18n.Trans, create one for
20 * Return the non-localised bundle of the given name.
23 * the name of the bundle to load
27 static public ResourceBundle
getBundle(String name
) {
28 return ResourceBundle
.getBundle(Bundles
.class.getPackage().getName()
29 + "." + name
, new FixedResourceBundleControl(confDir
));
33 * Return the localised bundle of the given name and {@link Locale}.
36 * the name of the bundle to load
38 * the {@link Locale} to use
40 * @return the localised bundle
42 static public ResourceBundle
getBundle(String name
, Locale locale
) {
43 return ResourceBundle
.getBundle(Bundles
.class.getPackage().getName()
44 + "." + name
, locale
, new FixedResourceBundleControl(confDir
));
48 * Set the primary configuration directory to look for <tt>.properties</tt>
51 * All {@link ResourceBundle}s returned by this class after that point will
52 * respect this new directory.
57 static public void setDirectory(String confDir
) {
58 Bundles
.confDir
= confDir
;
62 * Return the configuration directory where to try to find the
63 * <tt>.properties</tt> files in priority.
65 * @return the configuration directory
67 static private String
getConfDir() {
68 // Do not override user-supplied config directory (see --help)
69 if (Bundles
.confDir
!= null)
70 return Bundles
.confDir
;
73 ResourceBundle bundle
= ResourceBundle
.getBundle(Bundles
.class
74 .getPackage().getName() + "." + "jvcard",
75 Locale
.getDefault(), new FixedResourceBundleControl(null));
77 String configDir
= bundle
.getString("CONFIG_DIR");
78 if (configDir
!= null && configDir
.trim().length() > 0)
80 } catch (Exception e
) {