01: /*
02: * Created on 10 juin 2005
03: * SalomeTMF is a Test Managment Framework
04: * Copyright (C) 2005 France Telecom R&D
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
21: *
22: * Contact: mikael.marche@rd.francetelecom.com
23: */
24: package org.objectweb.salome_tmf.tools.languages;
25:
26: import java.util.Locale;
27: import java.util.ResourceBundle;
28:
29: import org.objectweb.salome_tmf.api.Api;
30: import org.objectweb.salome_tmf.tools.encrypt_prop.configDBTool;
31:
32: public class Language {
33: /** Static variable */
34: private static Language language = null;
35:
36: /** Local variable */
37: Locale currentLocale = null;
38:
39: /** For the resource file */
40: ResourceBundle i18n = null;
41: ResourceBundle i18nErr = null;
42: ResourceBundle i18nLog = null;
43:
44: /** Get the instance of the language */
45: public static Language getInstance() {
46: if (language == null) {
47: language = new Language();
48: }
49: return language;
50: }
51:
52: /** Constructor of the language */
53: private Language() {
54: Locale locale;
55: /*ResourceBundle localeProperties = ResourceBundle.getBundle(
56: "org/objectweb/salome_tmf/tools/languages/languageConf");
57: */
58: // \warning : if locale is empty then locale du i18n.properties
59: // else si locale non-présente then locale = locale JVM
60: //locale = new Locale(localeProperties.getString("locale"));
61: locale = new Locale(configDBTool.locale);
62: setLocale(locale);
63: }
64:
65: /** Set the local values */
66: public void setLocale(Locale locale) {
67: currentLocale = locale;
68: i18n = ResourceBundle.getBundle(
69: "org/objectweb/salome_tmf/tools/languages/i18n",
70: currentLocale);
71: //i18nErr = ResourceBundle.getBundle(
72: // "org/objectweb/salome_tmf/tools/languages/i18nErr", currentLocale);
73: //i18nLog = ResourceBundle.getBundle(
74: // "org/objectweb/salome_tmf/tools/languages/i18nLog", currentLocale);
75: }
76:
77: /* \brief Return the text corresponding to the key
78: * \param
79: */
80: public String getText(String key) {
81: return i18n.getString(key);
82: }
83:
84: /*
85: * \brief Return the log text corresponding to the key
86: * \param key : a log key belong i18nLog
87: */
88: public String getTextLog(String key) {
89: return i18nLog.getString(key);
90: }
91:
92: /*
93: * \brief Return the error text corresponding to the key
94: * \param key : an error key belong i18nErr
95: */
96: public String getTextErr(String key) {
97: return i18nErr.getString(key);
98: }
99: }
|