META-INF.resources.bower_components.cldrjs.src.item.lookup.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
define([
"../bundle/parent_lookup",
"../path/normalize",
"../resource/get",
"../resource/set",
"../util/json/merge"
], function (bundleParentLookup, pathNormalize, resourceGet, resourceSet, jsonMerge) {
var lookup;
lookup = function (Cldr, locale, path, attributes, childLocale) {
var normalizedPath, parent, value;
// 1: Finish recursion
// 2: Avoid infinite loop
if (typeof locale === "undefined" /* 1 */ || locale === childLocale /* 2 */) {
return;
}
// Resolve path
normalizedPath = pathNormalize(path, attributes);
// Check resolved (cached) data first
// 1: Due to #16, never use the cached resolved non-leaf nodes. It may not
// represent its leafs in its entirety.
value = resourceGet(Cldr._resolved, normalizedPath);
if (value && typeof value !== "object" /* 1 */) {
return value;
}
// Check raw data
value = resourceGet(Cldr._raw, normalizedPath);
if (!value) {
// Or, lookup at parent locale
parent = bundleParentLookup(Cldr, locale);
value = lookup(Cldr, parent, path, jsonMerge(attributes, {bundle: parent}), locale);
}
if (value) {
// Set resolved (cached)
resourceSet(Cldr._resolved, normalizedPath, value);
}
return value;
};
return lookup;
});