01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.base.test;
17:
18: import java.util.Locale;
19:
20: import javax.servlet.http.HttpServletRequest;
21:
22: import de.odysseus.calyxo.base.I18nSupport;
23:
24: /**
25: *
26: * @author Christoph Beck
27: */
28: public class TestI18nSupport extends I18nSupport {
29: private Locale locale;
30:
31: public Locale getLocale(HttpServletRequest request) {
32: return locale;
33: }
34:
35: public void setLocale(HttpServletRequest request, Locale locale) {
36: this .locale = locale;
37: }
38:
39: protected String lookupMessage(Locale locale, String bundle,
40: String key, Object[] args) {
41: StringBuffer result = new StringBuffer();
42: result.append(locale.getLanguage());
43: result.append('.');
44: result.append(bundle);
45: result.append('.');
46: result.append(key);
47: result.append('(');
48: for (int i = 0; i < args.length; i++) {
49: if (i > 0) {
50: result.append(',');
51: }
52: result.append(args[i]);
53: }
54: result.append(')');
55: return result.toString();
56: }
57:
58: protected String lookupResource(Locale locale, String bundle,
59: String key) {
60: StringBuffer result = new StringBuffer();
61: result.append(locale.getLanguage());
62: result.append('.');
63: result.append(bundle);
64: result.append('.');
65: result.append(key);
66: return result.toString();
67: }
68: }
|