mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
Bug#3232 (Support res://[resourceBundleName]/[key] style of resources)
This commit is contained in:
parent
22a269dfa4
commit
a7fc0a887a
@ -71,13 +71,33 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
|
||||
String caption = element.attributeValue("caption");
|
||||
|
||||
if (!StringUtils.isEmpty(caption)) {
|
||||
if (caption.startsWith("res://") && resourceBundle != null) {
|
||||
caption = resourceBundle.getString(caption.substring(6));
|
||||
}
|
||||
caption = loadResourceString(caption);
|
||||
component.setCaption(caption);
|
||||
}
|
||||
}
|
||||
|
||||
protected String loadResourceString(String caption) {
|
||||
if (caption.startsWith("res://")) {
|
||||
String path = caption.substring(6);
|
||||
final String[] strings = path.split("/");
|
||||
if (strings.length == 1) {
|
||||
if (resourceBundle != null) {
|
||||
caption = resourceBundle.getString(strings[0]);
|
||||
}
|
||||
} else if (strings.length == 2) {
|
||||
try {
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle(strings[0], getLocale());
|
||||
bundle.getString(strings[1]);
|
||||
} catch (Throwable e) {
|
||||
// Do nothing
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
return caption;
|
||||
}
|
||||
|
||||
protected void loadAlign(Component component, Element element) {
|
||||
final String align = element.attributeValue("align");
|
||||
if (!StringUtils.isBlank(align)) {
|
||||
|
@ -28,9 +28,7 @@ public class LabelLoader extends ComponentLoader {
|
||||
|
||||
String caption = element.attributeValue("value");
|
||||
if (!StringUtils.isEmpty(caption)) {
|
||||
if (caption.startsWith("res://") && resourceBundle != null) {
|
||||
caption = resourceBundle.getString(caption.substring(6));
|
||||
}
|
||||
caption = loadResourceString(caption);
|
||||
component.setCaption(caption);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user