01: package org.radeox.macro;
02:
03: import java.util.Locale;
04: import java.util.ResourceBundle;
05:
06: import org.apache.commons.logging.Log;
07: import org.apache.commons.logging.LogFactory;
08: import org.radeox.api.engine.context.InitialRenderContext;
09: import org.radeox.api.engine.context.RenderContext;
10:
11: /*
12: * This file is part of "SnipSnap Radeox Rendering Engine".
13: *
14: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
15: * All Rights Reserved.
16: *
17: * Please visit http://radeox.org/ for updates and contact.
18: *
19: * --LICENSE NOTICE--
20: * Licensed under the Apache License, Version 2.0 (the "License");
21: * you may not use this file except in compliance with the License.
22: * You may obtain a copy of the License at
23: *
24: * http://www.apache.org/licenses/LICENSE-2.0
25: *
26: * Unless required by applicable law or agreed to in writing, software
27: * distributed under the License is distributed on an "AS IS" BASIS,
28: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29: * See the License for the specific language governing permissions and
30: * limitations under the License.
31: * --LICENSE NOTICE--
32: */
33:
34: public abstract class LocalePreserved extends Preserved implements
35: LocaleMacro {
36: private static Log log = LogFactory.getLog(LocalePreserved.class);
37:
38: private String name;
39:
40: public String getName() {
41: return name;
42: }
43:
44: public void setInitialContext(InitialRenderContext context) {
45: super .setInitialContext(context);
46: Locale languageLocale = (Locale) context
47: .get(RenderContext.LANGUAGE_LOCALE);
48: String languageName = (String) context
49: .get(RenderContext.LANGUAGE_BUNDLE_NAME);
50: ResourceBundle messages = ResourceBundle.getBundle(
51: languageName, languageLocale);
52:
53: Locale inputLocale = (Locale) context
54: .get(RenderContext.INPUT_LOCALE);
55: String inputName = (String) context
56: .get(RenderContext.INPUT_BUNDLE_NAME);
57: ResourceBundle inputMessages = ResourceBundle.getBundle(
58: inputName, inputLocale);
59:
60: name = inputMessages.getString(getLocaleKey() + ".name");
61:
62: try {
63: description = messages.getString(getLocaleKey()
64: + ".description");
65: } catch (Exception e) {
66: log.warn("Cannot read description from properties "
67: + inputName + " for " + getLocaleKey());
68: }
69: }
70: }
|