Reload resource bundle, don't throw expectation for missing resource
git-svn-id: https://svn.libreccm.org/ccm/trunk@5862 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1de5f0f7d2
commit
65f587b0ae
|
|
@ -38,6 +38,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.PropertyResourceBundle;
|
import java.util.PropertyResourceBundle;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
@ -381,19 +382,25 @@ public class FreeMarkerPresentationManager implements PresentationManager {
|
||||||
|
|
||||||
private class GetLocalizedText implements TemplateMethodModelEx {
|
private class GetLocalizedText implements TemplateMethodModelEx {
|
||||||
|
|
||||||
private final ResourceBundle resourceBundle;
|
// private final ResourceBundle resourceBundle;
|
||||||
|
private final ThemeResourceBundleControl control;
|
||||||
|
private final String bundleName;
|
||||||
|
private final Locale locale;
|
||||||
|
|
||||||
public GetLocalizedText(final ServletContext servletContext,
|
public GetLocalizedText(final ServletContext servletContext,
|
||||||
final String themePath,
|
final String themePath,
|
||||||
final String language) {
|
final String language) {
|
||||||
|
|
||||||
final String bundleName = String.format("%stexts", themePath);
|
// final String bundleName = String.format("%stexts", themePath);
|
||||||
final ThemeResourceBundleControl control
|
// final ThemeResourceBundleControl control
|
||||||
= new ThemeResourceBundleControl(
|
// = new ThemeResourceBundleControl(
|
||||||
servletContext);
|
// servletContext);
|
||||||
resourceBundle = ResourceBundle.getBundle(bundleName,
|
// resourceBundle = ResourceBundle.getBundle(bundleName,
|
||||||
new Locale(language),
|
// new Locale(language),
|
||||||
control);
|
// control);
|
||||||
|
control = new ThemeResourceBundleControl(servletContext);
|
||||||
|
bundleName = String.format("%stexts", themePath);
|
||||||
|
locale = new Locale(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -410,7 +417,15 @@ public class FreeMarkerPresentationManager implements PresentationManager {
|
||||||
.get(0))
|
.get(0))
|
||||||
.getAsString();
|
.getAsString();
|
||||||
|
|
||||||
return resourceBundle.getString(key);
|
final ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
|
||||||
|
locale,
|
||||||
|
control);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return bundle.getString(key);
|
||||||
|
} catch (MissingResourceException ex) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue