root / trunk / libraries / libUI / src / org / gvsig / gui / beans / Messages.java @ 10974
History | View | Annotate | Download (2.51 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
|
43 |
package org.gvsig.gui.beans; |
44 |
|
45 |
import java.util.Locale; |
46 |
|
47 |
/**
|
48 |
* Bridge class to provide internationalization services to the library.
|
49 |
* It uses the gvsig-i18n library as a backend, and includes its
|
50 |
* necessary initialization.
|
51 |
*
|
52 |
* @author Cesar Martinez Izquierdo
|
53 |
*
|
54 |
*/
|
55 |
public class Messages { |
56 |
/**
|
57 |
* Whether the class has been initialized
|
58 |
*/
|
59 |
private static boolean isInitialized = false; |
60 |
|
61 |
/**
|
62 |
* The name of the Java package containing this class
|
63 |
*/
|
64 |
private static final String packageName = Messages.class.getPackage().getName(); |
65 |
|
66 |
/**
|
67 |
* Loads the translations in the dictionary. It initializes the backend
|
68 |
* gvsig-i18n library
|
69 |
*
|
70 |
*/
|
71 |
private static void init() { |
72 |
if (!org.gvsig.i18n.Messages.hasLocales()) {
|
73 |
org.gvsig.i18n.Messages.addLocale(Locale.getDefault());
|
74 |
} |
75 |
org.gvsig.i18n.Messages.addResourceFamily(packageName+".resources.translations.text", Messages.class.getClassLoader(), packageName);
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Gets the translation associated with the provided translation key.
|
80 |
*
|
81 |
* @param key The translation key which identifies the target text
|
82 |
* @return The translation associated with the provided translation key.
|
83 |
*/
|
84 |
public static String getText(String key) { |
85 |
if (isInitialized==false) { |
86 |
init(); |
87 |
isInitialized = true;
|
88 |
} |
89 |
return org.gvsig.i18n.Messages.getText(key, packageName);
|
90 |
} |
91 |
|
92 |
} |