01: /* Labels.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Sep 21 10:55:09 2004, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2004 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.util.resource;
20:
21: import org.zkoss.util.resource.impl.LabelLoader;
22: import org.zkoss.xel.VariableResolver;
23:
24: /**
25: * Utilities to access labels. A label is a Locale-dependent string
26: * that is stored in i3-label*properties.
27: *
28: * @author tomyeh
29: */
30: public class Labels {
31: private Labels() {
32: } //prevent form misuse
33:
34: private static final LabelLoader _loader = new LabelLoader();
35:
36: /** Returns the label of the specified key based
37: * on the current Locale, or null if no found.
38: *
39: * <p>The current locale is given by {@link org.zkoss.util.Locales#getCurrent}.
40: */
41: public static final String getLabel(String key) {
42: return _loader.getLabel(key);
43: }
44:
45: /** Resets all cached labels and next call to {@link #getLabel}
46: * will cause re-loading i3-label*.proerties.
47: */
48: public static final void reset() {
49: _loader.reset();
50: }
51:
52: /** Sets the variable resolver, which is used if an EL expression
53: * is specified.
54: *
55: * <p>Default: no resolver at all.
56: *
57: * @return the previous resolver, or null if no resolver.
58: */
59: public static final VariableResolver setVariableResolver(
60: VariableResolver resolv) {
61: return _loader.setVariableResolver(resolv);
62: }
63:
64: /** Registers a locator which is used to load i3-label*.properties
65: * from other resource, such as servlet contexts.
66: */
67: public static final void register(LabelLocator locator) {
68: _loader.register(locator);
69: }
70: }
|