Statistics
| Revision:

root / trunk / extensions / extQuickInfo / src / org / gvsig / quickInfo / i18n / Messages.java @ 27817

History | View | Annotate | Download (2.21 KB)

1
package org.gvsig.quickInfo.i18n;
2

    
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *  
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24

    
25
import java.util.Locale;
26

    
27
/**
28
 * Bridge class to provide internationalization services to the library.
29
 * It uses the gvsig-i18n library as a backend, and includes its
30
 * necessary initialization.
31
 * 
32
 * @author Cesar Martinez Izquierdo
33
 */
34
public class Messages {
35
        /**
36
         * Whether the class has been initialized
37
         */
38
        private static boolean isInitialized = false;
39
        
40
        /**
41
         * The name of the Java package containing this class
42
         */
43
        private static final String packageName = Messages.class.getPackage().getName();
44
        
45
        /**
46
         * Loads the translations in the dictionary. It initializes the backend
47
         * gvsig-i18n library
48
         *
49
         */
50
        private static void init() {
51
                if (!org.gvsig.i18n.Messages.hasLocales()) {
52
                        org.gvsig.i18n.Messages.addLocale(Locale.getDefault());
53
                }
54
                org.gvsig.i18n.Messages.addResourceFamily(packageName+".resources.translations.text", Messages.class.getClassLoader(), packageName);
55
        }
56
        
57
        /**
58
         * Gets the translation associated with the provided translation key.
59
         * 
60
         * @param key The translation key which identifies the target text
61
         * @return The translation associated with the provided translation key.
62
         */
63
        public static String getText(String key) {
64
                if (isInitialized==false) {
65
                        init();
66
                        isInitialized = true;
67
                }
68
                return org.gvsig.i18n.Messages.getText(key, packageName);
69
        }
70

    
71
}