Resource Fallback auf unqualifizierte Resourcen-IDs
This commit is contained in:
parent
92c50c8e48
commit
5cd78f58a9
@ -7,14 +7,29 @@ public class I18N {
|
|||||||
|
|
||||||
private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main");
|
private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main");
|
||||||
|
|
||||||
public static String getText(final String textProperty) {
|
/**
|
||||||
String textValue;
|
* Loads a String resource from the *.properties files.
|
||||||
try{
|
*
|
||||||
textValue = I18N.TEXTS.getString(textProperty);
|
* @param optionallyQualifiedTextProperty
|
||||||
}catch(MissingResourceException e){
|
* ID of the resource, optionally qualified module the module name,
|
||||||
textValue = "./. " + textProperty;
|
* e.g. "customer.name" (preferred) or simply "name" (legacy).
|
||||||
|
* @return the String resource, e.g. a label or message, usually to be displayed to the user
|
||||||
|
*/
|
||||||
|
public static String getText(final String optionallyQualifiedTextProperty) {
|
||||||
|
String textValue = getTextImpl(optionallyQualifiedTextProperty);
|
||||||
|
return textValue != null ? textValue : "./. " + optionallyQualifiedTextProperty;
|
||||||
}
|
}
|
||||||
return textValue;
|
|
||||||
|
public static String getTextImpl(final String optionallyQualifiedTextProperty) {
|
||||||
|
try {
|
||||||
|
return I18N.TEXTS.getString(optionallyQualifiedTextProperty);
|
||||||
|
} catch(MissingResourceException e1) {
|
||||||
|
String[] parts = optionallyQualifiedTextProperty.split(".", 2);
|
||||||
|
if ( parts.length > 1 ) {
|
||||||
|
return getTextImpl(parts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user