01: package org.caramba.spring;
02:
03: import org.caramba.i18n.AbstractMessageResources;
04: import org.springframework.context.ApplicationContext;
05:
06: import java.util.Locale;
07: import java.util.Map;
08:
09: /**
10: * This {@link org.caramba.i18n.MessageResources} implementation uses the in18 support of spring. The applicationContext
11: * provides the translated messages.
12: * @author Pieter Degraeuwe
13: */
14: public class SpringMessageResources extends AbstractMessageResources {
15: private ApplicationContext ctx;
16:
17: public SpringMessageResources(ApplicationContext pCtx) {
18: ctx = pCtx;
19: }
20:
21: public String getMessage(String key, Object args[]) {
22: return ctx.getMessage(key, args, null);
23: }
24:
25: public String getMessage(Locale locale, String key, Object args[]) {
26: return ctx.getMessage(key, args, locale);
27: }
28: }
|