diff --git a/web/src/main/java/de/hsadmin/web/I18N.java b/web/src/main/java/de/hsadmin/web/I18N.java index df14604..4aadac6 100644 --- a/web/src/main/java/de/hsadmin/web/I18N.java +++ b/web/src/main/java/de/hsadmin/web/I18N.java @@ -7,14 +7,29 @@ public class I18N { private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main"); - public static String getText(final String textProperty) { - String textValue; - try{ - textValue = I18N.TEXTS.getString(textProperty); - }catch(MissingResourceException e){ - textValue = "./. " + textProperty; + /** + * Loads a String resource from the *.properties files. + * + * @param optionallyQualifiedTextProperty + * ID of the resource, optionally qualified module the module name, + * 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; + } + + 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 textValue; + return null; } }