Web UI Framework localization - bundle collector utility
On the client side, you can index localization bundle files from different directories of the application using the JavaScript bundle collector and collator utility.
- Collects, into an index file, bundles defined in multiple JavaScript files (ending with
_bundle.js). The index file's format is the standard Java™ properties file format. The contents of
the bundle files, including comments, are included in the generated
bundle index file. In case, there are duplicate key entries in the
given bundle file, only the last such key is added to the bundle index
file. For example, consider the following bundle file with duplicate
key entries:
Ext.override(sc.plat.ui.Screen, { key1: "value1", key1: "value2" });
In the above scenario, the generated bundle index file will only contain the last duplicate entry for key1:
repository/eardata/<app>/war/<folder structure>/<full _bundle.js file name>/
sc.plat.ui.Screen/key1:value2 - Generates JavaScript bundle
files, given a localized bundle index file.
Once the bundle index file is localized, the corresponding localized JavaScript file must be regenerated.
The following shows examples of a bundle file (the _bundle.js file) and its corresponding entries in the bundle-index file.
JavaScript bundle file:
Ext.override(sc.plat.ui.Screen, {
b_First_Name: "First Name",
b_Last_Name: 'Last Name',
// {1} - last name, {0} - first name
b_Name: '{1}, {0}',
// a context insensitive comment
b_Search_View: "Search View"
});
Index file:
repository/eardata/<app>/war/<folder structure>/<full _bundle.js file name>/sc.plat.
ui.Screen/b_First_Name:First Name
repository/eardata/<app>/war/<folder structure>/<full _bundle.js file name>/sc.plat.
ui.Screen/b_Last_Name:Last Name
#//{1} - last name, {0} - first name
repository/eardata/<app>/war/<folder structure>/<full _bundle.js file name>/sc.plat.
ui.Screen/b_Name:{1}, {0}
#//a context insensitive comment
repository/eardata/<app>/war/<folder structure>/<full _bundle.js file name>/sc.plat.
ui.Screen/b_Search_View:Search View
<relativeFilePath>/<className>/<bundleKey>
where:
- <relativeFilePath> — The path relative to the installation directory.
- / : Separator used to separate the relative file path, class name, and key name.
- <className> — Name of the js class. For example, from the _bundle.js sample code: sc.plat.ui.Screen.
- <bundleKey> — Key whose value is to be localized. For example, from the _bundle.js sample code: b_First_Name.
The bundle utility uses the following utility class:
com.sterlingcommerce.ui.web.framework.build.utils.SCJSBundleUtil
- index
Generates an index of JavaScript bundle files.
This mode generates the following files:- bundle-index — Contains the entries from all _bundle.js files in the standard Java properties file format (refer to the sample contents provided above).
- warnings_indexMode.log — Warnings encountered when the tool is run in index mode.
- map
Generates localized JavaScript source files from the localized bundle index file.
Running the tool in map mode generates the following files:
- warnings_mapMode.log — Any warnings encountered during map mode.
- All localized js bundle files.
- updateThis mode should be used only if the localized bundle-index.properties file (for example, bundle-index_fr_FR.properties) is present in an old format:
1:First Name 2:Last Name 3:Search View #// (1) - last name. (0) - first name (should be picked up by collector) 4:(1), (0)
Running this mode generates the following files:- bundle-index.properties files — Updates the contents of the original (non-localized) and localized bundle-index.properties files with new contents. New files are not added.
- duplicate-keys-map file — Contains entries for all keys that have the same values. This file is required for map mode.
- update<locale code>.log — Generated for each localized bundle-index.properties file updated. it contains information about the old and new keys.
- update.log — Generated for the bundle-index.properties file (non-localized) updated. It contains information about the old and new keys.
- update_warnings.log — Generated for the bundle-index.properties file (non-localized) updated. It contains information about the old and new keys.
- warnings_indexMode.log — Contains warnings logged during index mode such as missing comments or duplicate keys.
- keys_updated — Contains the old numerical keys and the corresponding new keys in a properties file format.
The following tables show the arguments for the modes:
Arguments | Example |
---|---|
|
-Dprefix=<install>
|
Arguments | Example |
---|---|
|
|
update
Arguments | Example |
---|---|
|
|
You also can use an ant XML utility (jsUtil.xml) to invoke the utility class com.sterlingcommerce.ui.web.framework.build.utils.SCJSBundleUtil. This ant utility can be used to test and run the utility classes. This utility does not expose everything that is supported by the class, but the supported items that it does expose can be used in most cases. If you need to invoke the actual class with custom arguments, this XML file can be used as a sample source file.
The jsUtil.xml file is located in the <INSTALL_DIR>/bin folder after the Web UI Framework is installed. Sample code for invoking the ant utility in the two different modes is shown below:
- index mode
./sci_ant.sh -f jsUtil.xml bundle.index -Dsourcedir=<INSTALL_DIR>/repository/eardata/<app_dir>/war -Dindexdir=<INSTALL_DIR>/repository/eardata/<app_dir>/localization_index
- map mode
./sci_ant.sh -f jsUtil.xml bundle.map -Dsourcedir=<INSTALL_DIR>/repository/eardata/<app_dir>/war -Dindexdir=<INSTALL_DIR>/repository/eardata/<app_dir>/localization_index -Dindexfile=<INSTALL_DIR>/repository/eardata/<app_dir>/localization_index/ bundle-index_en_US.properties
- update modeNote: Run this mode only if you have localized the bundle-index.properties file in the format described previously.
(-Dprefix is optional.)./sci_ant.sh -f jsUtil.xml bundle.update -Dsourcedir=<INSTALL_DIR>/repository/eardata/<app_dir>/war -Dindexdir=<INSTALL_DIR>/repository/eardata/<app_dir>/localization_index -Dindexfile=<INSTALL_DIR>/repository/eardata/<app_dir>/localization_index/ bundle-index_en_US.properties -Dprefix=<INSTALL_DIR>
Running the bundle collector utility to localize Sterling Application Platform files
You can also use the bundle collector utility to generate index and bundle files for some platform_uifwk files like the dashboard bundle files.
The procedure is the same as above, except the directory structure would change to the following:
In <install>/repository/eardata/platform_uifwk/<version>/war/<directory containing required files>, <version> is the platform Sterling Application Platform being consumed by the application.