Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java @ 413:8a4c219fd0ee
Added a method to Resources that returns translated compound messages.
flys-artifacts/trunk@1877 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 10 May 2011 11:40:15 +0000 |
parents | 25593857b8f8 |
children | e0fec407a280 |
comparison
equal
deleted
inserted
replaced
412:046bd86ae41d | 413:8a4c219fd0ee |
---|---|
1 package de.intevation.flys.artifacts.resources; | 1 package de.intevation.flys.artifacts.resources; |
2 | 2 |
3 import java.text.MessageFormat; | |
3 import java.util.Locale; | 4 import java.util.Locale; |
4 import java.util.MissingResourceException; | 5 import java.util.MissingResourceException; |
5 import java.util.ResourceBundle; | 6 import java.util.ResourceBundle; |
6 | 7 |
7 import org.apache.log4j.Logger; | 8 import org.apache.log4j.Logger; |
79 return getMsg(locale, key, def); | 80 return getMsg(locale, key, def); |
80 } | 81 } |
81 | 82 |
82 | 83 |
83 /** | 84 /** |
85 * Returns a translated message based on a template specified by <i>key</i> | |
86 * that has necessary values to be filled in. | |
87 * | |
88 * @param meta The CallMeta object. | |
89 * @param key The key of the template in the resource bundle. | |
90 * @param def the default value if no template was found with <i>key</i>. | |
91 * @param args The arguments that are necessary for the template. | |
92 * | |
93 * @return a translated string. | |
94 */ | |
95 public static String getMsg( | |
96 CallMeta meta, | |
97 String key, | |
98 String def, | |
99 Object[] args) | |
100 { | |
101 String template = getMsg(meta, key, null); | |
102 | |
103 if (template == null) { | |
104 return def; | |
105 } | |
106 | |
107 return MessageFormat.format(template, args); | |
108 } | |
109 | |
110 | |
111 /** | |
84 * This method returns the translated value for <i>key</i> or <i>def</i> if | 112 * This method returns the translated value for <i>key</i> or <i>def</i> if |
85 * <i>key</i> is not existing in the resource bundle. | 113 * <i>key</i> is not existing in the resource bundle. |
86 * | 114 * |
87 * @param locale The locale. | 115 * @param locale The locale. |
88 * @param key The key that should be translated. | 116 * @param key The key that should be translated. |