}
private AWElement localizedElement (AWComponent component)
{
boolean UseStaticCache = !AWConcreteApplication.IsRapidTurnaroundEnabled;
AWSingleLocaleResourceManager resourceManager = (AWSingleLocaleResourceManager)component.resourceManager();
AWElement localizedElement = (AWElement)_localizedElements.get(resourceManager);
if (localizedElement == null) {
synchronized (this) {
localizedElement = (AWElement)_localizedElements.get(resourceManager);
if (localizedElement == null) {
Map elementCache = null;
String stringTableEntry = null;
Map localizedStringsHashtable = loadLocalizedAWLStrings(component);
if (localizedStringsHashtable != null && _key != null) {
if (!UseStaticCache) {
elementCache = (Map)localizedStringsHashtable.get("___cache___");
if (elementCache != null) {
// check if we've inherited some other locales map
if (elementCache.get("__RM__") != resourceManager) {
elementCache = null;
} else {
localizedElement = (AWElement)elementCache.get(_key);
}
}
if (elementCache == null) {
// we put a cache map in the ResourceService strings Map (hack!)
// Unfortunately, when en_US is copied to another locale we can inherit that
// cache, so we tag the cache and check for it (above)
elementCache = MapUtil.map();
localizedStringsHashtable.put("___cache___", elementCache);
elementCache.put("__RM__", resourceManager);
}
}
if (localizedElement == null) {
stringTableEntry = (String)localizedStringsHashtable.get(_key);
}
} else {
// Pseudo localizing?
if (resourceManager.pseudoLocalizingAll() && contentElement() != null) {
stringTableEntry = localizedStringForElement(contentElement());
stringTableEntry = resourceManager.pseudoLocalizeUnKeyed(stringTableEntry);
} else {
// No key, just use the template content as is
localizedElement = contentElement();
}
}