01: package com.xoetrope.langmgr;
02:
03: import net.xoetrope.xui.helper.ResourceBundleLoader;
04: import java.util.ResourceBundle;
05: import net.xoetrope.xui.XProject;
06:
07: /**
08: * <p>A resource bundle loader interface for a language resources. See the Localization chapter of the
09: * <i>XuiPro User Guide</i> for more detail.</p>
10: * <p>XUI uses standard property files for localization. These localization files can be set
11: * for an individual page (by setting the 'resource' attribute of the XPage
12: * element or for the component factory. The project's resource manager
13: * is used to identify the current locale and the name of the property file by default.</p>
14: *
15: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
16: * the GNU Public License (GPL), please see license.txt for more details. If
17: * you make commercial use of this software you must purchase a commercial
18: * license from Xoetrope.</p>
19: * <p> $Revision: 1.3 $</p>
20: */
21: public class LanguageDatabaseResourceBundleLoader implements
22: ResourceBundleLoader {
23: private static String keyField = "id";
24:
25: protected XProject currentProject;
26:
27: /**
28: * Create a new resource bundle
29: */
30: public LanguageDatabaseResourceBundleLoader(XProject project) {
31: currentProject = project;
32: }
33:
34: /**
35: * Get the named resource bundle. The name may correspond to a context e.g. a
36: * page or part of an application.
37: * @param name the language name
38: * @return the language resource bundle
39: */
40: public ResourceBundle getResourceBundle(String name) {
41: return new LanguageDatabaseResourceBundle(currentProject,
42: keyField, name);
43: }
44:
45: /**
46: * Set the key field name.
47: * @param keyFieldName the field name
48: */
49: public static void setKeyField(String keyFieldName) {
50: keyField = keyFieldName;
51: }
52: }
|