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