if (localeName.equalsIgnoreCase("default")) { //$NON-NLS-1$
// process only bundleName.properties
fireBundleLoadCallback();
return;
} else {
StringTokenizer st = new StringTokenizer(localeName, '_');
if (st.countTokens() > 0) {
String lang = st.tokenAt(0);
// 2. fetch bundleName_lang.properties
// 3. fetch bundleName_lang_country.properties
currentAttemptUrl = path + bundleName + "_" + lang + PROPERTIES_EXTENSION + "?rand=" + System.currentTimeMillis();
// IE caches the file and causes an issue with the request
if (!isSupportedLanguage(lang) || bundleCache.containsKey(currentAttemptUrl)) {
langCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl)));
} else {
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentAttemptUrl); //$NON-NLS-1$ //$NON-NLS-2$
// Caching causing some strange behavior with IE6.
// TODO: Investigate caching issue.
requestBuilder.setHeader("Cache-Control", "no-cache");
try {
requestBuilder.sendRequest(null, langCallback);
} catch (RequestException e) {
Window.alert("lang: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
fireBundleLoadCallback();
}
}
} else if (st.countTokens() == 0) {
// already fetched
fireBundleLoadCallback();
return;
}
}
}
};
langCallback = new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert("langCallback: " + exception.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
fireBundleLoadCallback();
}
public void onResponseReceived(Request request, Response response) {
String propertiesFileText = response.getText();
// build a simple map of key/value pairs from the properties file
if (response.getStatusCode() == Response.SC_OK) {
bundle = PropertiesUtil.buildProperties(propertiesFileText, bundle);
if (response instanceof FakeResponse == false) {
// this is a real bundle load
bundleCache.put(currentAttemptUrl, propertiesFileText);
}
} else {
// put empty bundle in cache (not found, but we want to remember it was not found)
bundleCache.put(currentAttemptUrl, "");
}
StringTokenizer st = new StringTokenizer(localeName, '_');
if (st.countTokens() == 2) {
// 3. fetch bundleName_lang_country.properties
currentAttemptUrl = path + bundleName + "_" + localeName + PROPERTIES_EXTENSION + "?rand=" + System.currentTimeMillis();
if (!isSupportedLanguage(localeName) || bundleCache.containsKey(currentAttemptUrl)) {
langCountryCallback.onResponseReceived(null, new FakeResponse(bundleCache.get(currentAttemptUrl)));
} else {