Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / Messages.java @ 40561

History | View | Annotate | Download (2.25 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program 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
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.gui.beans;
26

    
27
import java.util.Locale;
28

    
29
/**
30
 * Bridge class to provide internationalization services to the library.
31
 * It uses the gvsig-i18n library as a backend, and includes its
32
 * necessary initialization.
33
 *
34
 * @author Cesar Martinez Izquierdo
35
 *
36
 */
37
public class Messages {
38
        /**
39
         * Whether the class has been initialized
40
         */
41
        private static boolean isInitialized = false;
42

    
43
        /**
44
         * The name of the Java package containing this class
45
         */
46
        private static final String packageName = Messages.class.getPackage().getName();
47

    
48
        /**
49
         * Loads the translations in the dictionary. It initializes the backend
50
         * gvsig-i18n library
51
         *
52
         */
53
        private static void init() {
54
                if (!org.gvsig.i18n.Messages.hasLocales()) {
55
                        org.gvsig.i18n.Messages.addLocale(Locale.getDefault());
56
                }
57
                org.gvsig.i18n.Messages.addResourceFamily(packageName+".resources.translations.text", Messages.class.getClassLoader(), packageName);
58
        }
59

    
60
        /**
61
         * Gets the translation associated with the provided translation key.
62
         *
63
         * @param key The translation key which identifies the target text
64
         * @return The translation associated with the provided translation key.
65
         */
66
        public static String getText(String key) {
67
                if (isInitialized==false) {
68
                        init();
69
                        isInitialized = true;
70
                }
71
                return org.gvsig.i18n.Messages.getText(key, packageName);
72
        }
73

    
74
}