Revision 7280

View differences:

trunk/libraries/libCq CMS for java.old/src/org/cresques/i18n/Messages.java
1
/* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
2
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
3
*
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
17
*
18
* For more information, contact:
19
*
20
*  Generalitat Valenciana
21
*   Conselleria d'Infraestructures i Transport
22
*   Av. Blasco Ib??ez, 50
23
*   46010 VALENCIA
24
*   SPAIN
25
*
26
*      +34 963862235
27
*   gvsig@gva.es
28
*      www.gvsig.gva.es
29
*
30
*    or
31
*
32
*   IVER T.I. S.A
33
*   Salamanca 50
34
*   46005 Valencia
35
*   Spain
36
*
37
*   +34 963163400
38
*   dac@iver.es
39
*/
40

  
41

  
42
package org.cresques.i18n;
43

  
44
import java.util.Locale;
45

  
46
/**
47
* Bridge class to provide internationalization services to the library.
48
* It uses the gvsig-i18n library as a backend, and includes its
49
* necessary initialization.
50
* 
51
* @author Cesar Martinez Izquierdo
52
*
53
*/
54
public class Messages {
55
	/**
56
	 * Whether the class has been initialized
57
	 */
58
	private static boolean isInitialized = false;
59
	
60
	/**
61
	 * The name of the Java package containing this class
62
	 */
63
	private static final String packageName = Messages.class.getPackage().getName();
64
	
65
	/**
66
	 * Loads the translations in the dictionary. It initializes the backend
67
	 * gvsig-i18n library
68
	 *
69
	 */
70
	private static void init() {
71
		if (!org.gvsig.i18n.Messages.hasLocales()) {
72
			org.gvsig.i18n.Messages.addLocale(Locale.getDefault());
73
		}
74
		org.gvsig.i18n.Messages.addResourceFamily(packageName+".resources.translations.text", Messages.class.getClassLoader(), packageName);
75
	}
76
	
77
	/**
78
	 * Gets the translation associated with the provided translation key.
79
	 * 
80
	 * @param key The translation key which identifies the target text
81
	 * @return The translation associated with the provided translation key.
82
	 */
83
	public static String getText(String key) {
84
		if (isInitialized==false) {
85
			init();
86
			isInitialized = true;
87
		}
88
		return org.gvsig.i18n.Messages.getText(key, packageName);
89
	}
90

  
91
}
92

  
0 93

  

Also available in: Unified diff