001: package salomeTMF_plug.pluginxlsxml.language;
002:
003: import java.util.Locale;
004: import java.util.ResourceBundle;
005:
006: import org.objectweb.salome_tmf.api.Api;
007:
008: /**
009: * * Created on 10 juin 2005 * SalomeTMF is a Test Managment Framework *
010: * Copyright (C) 2005 France Telecom R&D * * This library is free software; you
011: * can redistribute it and/or * modify it under the terms of the GNU Lesser
012: * General Public * License as published by the Free Software Foundation; either *
013: * version 2 of the License, or (at your option) any later version. * * This
014: * library is distributed in the hope that it will be useful, * but WITHOUT ANY
015: * WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS
016: * FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for
017: * more details. * * You should have received a copy of the GNU Lesser General
018: * Public * License along with this library; if not, write to the Free Software *
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *
020: * Contact: mikael.marche@rd.francetelecom.com
021: */
022:
023: public class Language {
024: /** Static variable */
025: private static Language language = null;
026:
027: /** Local variable */
028: Locale currentLocale = null;
029:
030: /** For the resource file */
031: ResourceBundle i18n = null;
032:
033: ResourceBundle i18nErr = null;
034:
035: ResourceBundle i18nLog = null;
036:
037: /**
038: * Get the instance of the language
039: *
040: * @return language
041: */
042: public static Language getInstance() {
043: if (language == null) {
044: language = new Language();
045: }
046: return language;
047: }
048:
049: /** Constructor of the language */
050: private Language() {
051: Locale locale;
052: /*
053: * ResourceBundle localeProperties = ResourceBundle.getBundle(
054: * "salomeTMF_plug/pluginxlsxml/language/languageConf");
055: */
056: // \warning : if locale is empty then locale du i18n.properties
057: // if locale doesn't exist then locale = JVM locale
058: // locale = new Locale(localeProperties.getString("locale"));
059: locale = new Locale(Api.getUsedLocale());
060: setLocale(locale);
061: }
062:
063: /**
064: * Set the local values
065: *
066: * @param locale
067: * get Language of SalomeTMF
068: */
069: public void setLocale(Locale locale) {
070: currentLocale = locale;
071: i18n = ResourceBundle.getBundle(
072: "salomeTMF_plug/pluginxlsxml/language/i18n",
073: currentLocale);
074: // i18nErr = ResourceBundle.getBundle(
075: // "salomeTMF_plug/pluginxlsxml/language", currentLocale);
076: // i18nLog = ResourceBundle.getBundle(
077: // "salomeTMF_plug/pluginxlsxml/language", currentLocale);
078: }
079:
080: /*
081: * \brief Return the text corresponding to the key \param
082: */
083: /**
084: * Get text in parameter
085: *
086: * @param key
087: * string to search
088: * @return string found
089: */
090: public String getText(String key) {
091: return i18n.getString(key);
092: }
093:
094: /*
095: * \brief Return the log text corresponding to the key \param key : a log
096: * key belong i18nLog
097: */
098: /**
099: * Write an error if string not found
100: *
101: * @param key
102: * String to search
103: * @return string not found
104: */
105: public String getTextLog(String key) {
106: return i18nLog.getString(key);
107: }
108:
109: /*
110: * \brief Return the error text corresponding to the key \param key : an
111: * error key belong i18nErr
112: */
113: /**
114: * Return the error text corresponding to the key
115: *
116: * @param key
117: * an error key belong i18nErr
118: * @return an error
119: */
120: public String getTextErr(String key) {
121: return i18nErr.getString(key);
122: }
123: }
|