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: * Contact: mikael.marche@rd.francetelecom.com
21: */
22:
23: package salomeTMF_plug.helpgui.util;
24:
25: import java.util.Locale;
26: import java.util.ResourceBundle;
27:
28: import org.objectweb.salome_tmf.api.Api;
29:
30: /**
31: * Class that help to get text from differents file format
32: *
33: * @author Alexandre THOMAS
34: */
35: public class Language {
36:
37: /** Static variable */
38: private static Language language = null;
39:
40: /** Local variable */
41: Locale currentLocale = null;
42:
43: /** For the resource file */
44: ResourceBundle i18n = null;
45:
46: /** Get the instance of the language */
47: public static Language getInstance() {
48: if (language == null) {
49: language = new Language();
50: }
51: return language;
52: }
53:
54: /** Constructor of the language */
55: private Language() {
56: Locale locale;
57: /*ResourceBundle localeProperties = ResourceBundle.getBundle(
58: "salomeTMF_plug/helpgui/languages/languageConf");
59: */
60: // \warning : if locale is empty then locale du i18n.properties
61: // if locale doesn't exist then locale = JVM locale
62: //locale = new Locale(localeProperties.getString("locale"));
63: locale = new Locale(Api.getUsedLocale());
64: setLocale(locale);
65: }
66:
67: /** Set the local values */
68: public void setLocale(Locale locale) {
69: currentLocale = locale;
70: i18n = ResourceBundle.getBundle(
71: "salomeTMF_plug/helpgui/languages/i18n", currentLocale);
72: //i18nErr = ResourceBundle.getBundle(
73: // "salomeTMF_plug/gen_doc_xml/languages", currentLocale);
74: //i18nLog = ResourceBundle.getBundle(
75: // "salomeTMF_plug/gen_doc_xml/languages", currentLocale);
76: }
77:
78: //////////////////////////////////////////////////////////////////////////
79: /* Return the text corresponding to the key */
80: public String getText(String key) {
81: return i18n.getString(key);
82: }
83: }
|