# HG changeset patch # User Ingo Weinzierl # Date 1305027615 0 # Node ID 8a4c219fd0ee8e14d0fa5afe1ae53602b9d7604c # Parent 046bd86ae41d30d2f32798e52db543458e14a0c0 Added a method to Resources that returns translated compound messages. flys-artifacts/trunk@1877 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 046bd86ae41d -r 8a4c219fd0ee flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue May 10 10:26:26 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue May 10 11:40:15 2011 +0000 @@ -1,3 +1,8 @@ +2011-05-10 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/resources/Resources.java: + Added new methods to retrieve translated compound messages. + 2011-05-10 Ingo Weinzierl * src/main/java/de/intevation/flys/exports/OutGenerator.java: Added a diff -r 046bd86ae41d -r 8a4c219fd0ee flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java Tue May 10 10:26:26 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java Tue May 10 11:40:15 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.resources; +import java.text.MessageFormat; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -81,6 +82,33 @@ /** + * Returns a translated message based on a template specified by key + * that has necessary values to be filled in. + * + * @param meta The CallMeta object. + * @param key The key of the template in the resource bundle. + * @param def the default value if no template was found with key. + * @param args The arguments that are necessary for the template. + * + * @return a translated string. + */ + public static String getMsg( + CallMeta meta, + String key, + String def, + Object[] args) + { + String template = getMsg(meta, key, null); + + if (template == null) { + return def; + } + + return MessageFormat.format(template, args); + } + + + /** * This method returns the translated value for key or def if * key is not existing in the resource bundle. *