Note |
---|
DRAFT Note that this tutorial has not yet been updated to reflect a recent (Oct. 28, 2013) change in the way strings are handled. |
Div | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||
|
...
Message bundles cannot contain arrays. Instead a namespace should be used to group messagekeys message keys together. This will require extra processing when using the messages. (See Using Message Bundles below). Note that the namespace should not include "."; , which is used for path parsing.
...
Message Bundles can also be resolved directly through an IoC Reference reference making use of the the stringBundle
property; which can be found an , which is automatically created for any panel component. This process is quite similar to how IoC References references to selectors are resolved.
Code Block | ||
---|---|---|
| ||
fluid.defaults("fluid.slidingPanel", { ... strings: { showText: "{that}.stringBundle.slidingPanelShowText", hideText: "{that}.stringBundle.slidingPanelHideText" } ... }); |
...
There are other, more complex cases , where an array of strings is required . To facilitate this a (for example, for a set of radio buttons or a drop-down). In these cases, a stringArrayIndex
in the components options needs to be specified. This defines both
- which strings to include and
- the order in which they should be returned
...
- .
It is accessed the same way that an individual string is referenced, except that reference should point to the key in the the stringArrayIndex
instead of a single string name. In the example below, the stringArrayIndex
is used on line 4 to define the theme
string bundle, and the theme
string bundle is referenced on line 15:
Code Block | ||||
---|---|---|---|---|
| ||||
fluid.defaults("fluid.prefs.panel.contrast", { ... stringArrayIndex: { theme: ["contrast-default", "contrast-bw", "contrast-wb", "contrast-by", "contrast-yb", "contrast-lgdg"] }, protoTree: { label: {messagekey: "contrastLabel"}, expander: { type: "fluid.renderer.selection.inputs", rowID: "themeRow", labelID: "themeLabel", inputID: "themeInput", selectID: "theme-radio", tree: { optionnames: "${{that}.stringBundle.theme}", // IoC reference to the array of strings optionlist: "${{that}.options.controlValues.theme}", selection: "${value}" } } } ... }); |
...
The strings can also be accessed directly, outside of either the context of IoC references or renderer protoTreeprotoTrees (for example, in an invoker function), by making function calls to the internal StringBundlestring bundle lookup()
method.
Code Block | ||
---|---|---|
| ||
that.stringBundle.lookup(value); // where value is either the string name or the key in the stringArrayIndex to lookup. |