Revision 42017

View differences:

tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/tools/impl/DefaultI18Manager.java
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
package org.gvsig.i18n.tools.impl;
25

  
26
import java.util.Locale;
27

  
28
import org.gvsig.i18n.Messages;
29
import org.gvsig.tools.i18n.I18nManager;
30

  
31
/**
32
 * This manager is in charge of providing with a richer text translation than
33
 * the one used by default.
34
 * 
35
 * 
36
 * @author gvSIG Team
37
 * 
38
 */
39
public class DefaultI18Manager implements I18nManager {
40

  
41
	public String getTranslation(String message) {
42
		return Messages.getText(message);
43
	}
44

  
45
        public String getTranslation(String message, String[] args) {
46
		return Messages.getText(message,args);
47
        }
48

  
49
	public void addResourceFamily(String family, ClassLoader loader,
50
			String callerName) {
51
		if (!Messages.hasLocales()) {
52
			Messages.addLocale(Locale.getDefault());
53
		}
54
		Messages.addResourceFamily(family, loader, callerName);
55
	}
56

  
57
}
0 58

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/MessagesClassLoader.java
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
package org.gvsig.i18n;
25

  
26
import java.io.File;
27
import java.net.MalformedURLException;
28
import java.net.URL;
29
import java.net.URLClassLoader;
30
import java.util.ArrayList;
31
import java.util.List;
32
import java.util.StringTokenizer;
33

  
34
/**
35
 * <p>This class offers a class loader which is able to load files from the specified
36
 * directories.</p>
37
 * 
38
 * @author C?sar Mart?nez Izquierdo (cesar.martinez@iver.es)
39
 *
40
 */
41
public class MessagesClassLoader extends URLClassLoader {
42
	
43
	/**
44
	 * <p>Creates a new class loader, which is able to load files from the directories
45
	 * specified as parameter.</p>
46
	 * 
47
	 * @param urls The list of directories which will be used to load files.
48
	 */
49
	public MessagesClassLoader(URL[] urls) {
50
		super(urls);
51
	}
52
	
53
	/**
54
	 * Loads a resource using the specified file name.
55
	 * 
56
	 * @param res The name of the resource to be loaded.
57
	 */
58
	public URL getResource(String res) {
59
		try {
60
			ArrayList resource = new ArrayList();
61
			StringTokenizer st = new StringTokenizer(res, "\\/");
62
			
63
			while (st.hasMoreTokens()) {
64
				String token = st.nextToken();
65
				resource.add(token);
66
			}
67
			URL ret = null;
68
			int currentUrl;
69
			URL[] urls = getURLs();
70
		
71
			for (currentUrl=0; currentUrl< urls.length; currentUrl++) {
72
				URL url = urls[currentUrl];
73
				File file = new File(url.getFile());
74
				if (url.getFile().endsWith("/"))
75
					ret = getResource(file, resource);
76
			}
77
			
78
			if (ret != null) {
79
				return ret;
80
			}
81
		} catch (Exception e) {
82
			e.printStackTrace();
83
		}
84
		
85
		return super.getResource(res);
86
	}
87
	
88
	/**
89
	 * Busca recursivamente el recurso res en el directorio base. res es una
90
	 * lista de String's con los directorios del path y base es el directorio
91
	 * a partir del cual se busca dicho recurso. En cada ejecuci?n del m?todo
92
	 * se toma el primer elemento de res y se busca dicho directorio en el
93
	 * directorio base. Si se encuentra, ser? el directorio base para una
94
	 * nueva llamada.
95
	 *
96
	 * @param base Directorio desde donde parte la b?squeda del recurso.
97
	 * @param res Lista de strings con el path del recurso que se quiere
98
	 *        encontrar
99
	 *
100
	 * @return URL con el recurso
101
	 */
102
	private URL getResource(File base, List res) {
103
		File[] files = base.listFiles();
104
		
105
		String parte = (String) res.get(0);
106
		
107
		for (int i = 0; i < files.length; i++) {
108
			if (files[i].getName().compareTo(parte) == 0) {
109
				if (res.size() == 1) {
110
					try {
111
						return new URL("file:" + files[i].toString());
112
					} catch (MalformedURLException e) {
113
						return null;
114
					}
115
				} else {
116
					return getResource(files[i], res.subList(1, res.size()));
117
				}
118
			}
119
		}
120
		
121
		return null;
122
	}
123
}
124

  
125

  
0 126

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/Messages.java
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.i18n;
26

  
27
import java.io.File;
28
import java.io.IOException;
29
import java.io.InputStream;
30
import java.net.MalformedURLException;
31
import java.net.URL;
32
import java.text.MessageFormat;
33
import java.util.ArrayList;
34
import java.util.Enumeration;
35
import java.util.HashSet;
36
import java.util.IllegalFormatException;
37
import java.util.Iterator;
38
import java.util.List;
39
import java.util.Locale;
40
import java.util.Properties;
41
import java.util.Set;
42

  
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
/**
47
 * <p>This class offers some methods to provide internationalization services
48
 * to other projects. All the methods are static.</p>
49
 *
50
 * <p>The most useful method is {@link #getText(String) getText(key)} (and family),
51
 * which returns the translation associated
52
 * with the provided key. The class must be initialized before getText can be
53
 * used.</p>
54
 *
55
 * <p>The typical usage sequence would be:</p>
56
 * <ul>
57
 * <li>Add some locale to the prefered locales list: <code>Messages.addLocale(new Locale("es"))</code></li>
58
 * <li>Add some resource file containing translations: <code>Messages.addResourceFamily("text", new File("."))</code></li>
59
 * <li>And finaly getText can be used: <code>Messages.getText("aceptar")</code></li>
60
 * </ul>
61
 *
62
 * <p>The resource files are Java properties files, which contain <code>key=translation</code>
63
 * pairs, one
64
 * pair per line. These files must be encoded using iso-8859-1 encoding, and unicode escaped
65
 * sequences must be used to include characters outside the former encoding.
66
 * There are several ways to specify the property file to load, see the different
67
 * addResourceFamily methods for details.</p>
68
 *
69
 * @author Cesar Martinez Izquierdo (cesar.martinez@iver.es)
70
 *
71
 */
72
public class Messages {
73
    
74
    private static class FamilyDescriptor {
75
        String family = null;
76
        ClassLoader loader = null;
77
        String callerName = null;
78
        
79
        public FamilyDescriptor(String family, ClassLoader loader, String callerName ) {
80
            this.family  = family;
81
            this.loader = loader;
82
            this.callerName = callerName;
83
        }
84
    }
85
    
86
    private static Logger logger = LoggerFactory.getLogger("Messages");
87
    private static String _CLASSNAME = "org.gvsig.i18n.Messages";
88
    private static Locale currentLocale;
89

  
90
    /* Each entry will contain a hashmap with translations. Each hasmap
91
     * contains the translations for one language, indexed by the
92
     * translation key. The translations for language (i) in the preferred locales
93
     * list are contained in the position (i) of the localeResources list */
94
    private static ArrayList localeResources = new ArrayList();
95
    private static ArrayList preferredLocales = new ArrayList(); // contains the ordered list of prefered languages/locales (class Locale)
96
    private static Set notTranslatedKeys = new HashSet();
97

  
98

  
99
	/* Set of resource families and classloaders used to load i18n resources. */
100
	private static Set resourceFamilies = new HashSet();
101
	private static Set classLoaders = new HashSet();
102

  
103
        private static List familyDescriptors = new ArrayList();
104
        
105
	/*
106
	 * The language considered the origin of translations, which will
107
	 * (possibly) be stored in a property file without language suffix
108
	 * (ie: text.properties instead of text_es.properties).
109
	 */
110
	private static String baseLanguage = "es";
111
	private static Locale baseLocale = new Locale(baseLanguage);
112

  
113
	/**
114
	 * <p>Gets the localized message associated with the provided key.
115
	 * If the key is not in the dictionary, return the key and register
116
	 * the failure in the log.</p>
117
	 *
118
	 * <p>The <code>callerName</code> parameter is only
119
	 * used as a label when logging, so any String can be used. However, a
120
	 * meaningful String should be used, such as the name of the class requiring
121
	 * the translation services, in order to identify the source of the failure
122
	 * in the log.</p>
123
	 *
124
	 * @param key         An String which identifies the translation that we want to get.
125
	 * @param callerName  A symbolic name given to the caller of this method, to
126
	 *                    show it in the log if the key was not found
127
	 * @return            an String with the message associated with the provided key.
128
	 *                    If the key is not in the dictionary, return the key. If the key
129
	 *                    is null, return null.
130
	 */
131
	public static String getText(String key, String callerName) {
132
		if (key==null) {
133
			return null;
134
		}
135
		for (int numLocale=0; numLocale<localeResources.size(); numLocale++) {
136
			// try to get the translation for any of the languagues in the preferred languages list
137
			String translation = ((Properties)localeResources.get(numLocale)).getProperty(key);
138
			if (translation!=null && !translation.equals("")) {
139
				return translation;
140
			}
141
		}
142
                addNotTranslatedKey(key, callerName, true);
143
		return key;
144
	}
145

  
146
	public static String getText(String key,  String[] arguments, String callerName) {
147
		String translation = getText(key, callerName);
148
		if (translation!=null && arguments!=null ) {
149
			try {
150
				translation = MessageFormat.format(translation, arguments);
151
			}
152
			catch (IllegalFormatException ex) {
153
				logger.error(callerName+" -- Error formating key: "+key+" -- "+translation);
154
			}
155
		}
156
		return translation;
157
	}
158
	
159
	public static String translate(String message, String[] args) {
160
		String msg = message;
161
		if (msg == null) {
162
			return "";
163
		}
164
		msg = getText(msg, args);
165
		if (msg == null) {
166
			msg = "_" + message.replace("_", " ");
167
		}
168
		return msg;
169
	}
170

  
171
	public static String translate(String message) {
172
		String msg = message;
173
		if (msg == null) {
174
			return "";
175
		}
176
		msg = getText(msg, (String[]) null);
177
		if (msg == null || msg.startsWith("_")) {
178
			msg = "_" + message.replace("_", " ");
179
		}
180
		return msg;
181
	}
182

  
183
	/**
184
	 * <p>Gets the localized message associated with the provided key.
185
	 * If the key is not in the dictionary or the translation is empty,
186
	 * return the key and register the failure in the log.</p>
187
	 *
188
	 * @param key     An String which identifies the translation that we want to get.
189
	 * @return        an String with the message associated with the provided key.
190
	 *                If the key is not in the dictionary or the translation is empty,
191
	 *                return the key. If the key is null, return null.
192
	 */
193
	public static String getText(String key) {
194
		return getText(key, _CLASSNAME);
195
	}
196

  
197
	public static String getText(String key, String[] arguments) {
198
		return getText(key, arguments, _CLASSNAME);
199
	}
200

  
201
	
202
	/**
203
	 * <p>Gets the localized message associated with the provided key.
204
	 * If the key is not in the dictionary or the translation is empty,
205
	 * it returns null and the failure is only registered in the log if
206
	 * the param log is true.</p>
207
	 *
208
	 * @param key	An String which identifies the translation that we want
209
	 * 				to get.
210
	 * @param log	Determines whether log a key failure or not
211
	 * @return		an String with the message associated with the provided key,
212
	 * 				or null if the key is not in the dictionary or the
213
	 * 				translation is empty.
214
	 */
215
	public static String getText(String key, boolean log) {
216
		return getText(key, _CLASSNAME, log);
217
	}
218

  
219
	public static String getText(String key, String[] arguments, boolean log) {
220
		String translation = getText(key, _CLASSNAME, log);
221
		if (translation!=null && arguments!=null ) {
222
			try {
223
				translation = MessageFormat.format(translation, arguments);
224
			} catch (IllegalFormatException ex) {
225
				if (log) {
226
					logger.error(_CLASSNAME+" -- Error formating key: "+key+" -- "+translation);
227
				}
228
			}
229
		}
230
		return translation;
231
	}
232

  
233
	/**
234
	 * <p>Gets the localized message associated with the provided key.
235
	 * If the key is not in the dictionary, it returns null and the failure
236
	 * is only registered in the log if the param log is true.</p>
237
	 *
238
	 * @param key         An String which identifies the translation that we want to get.
239
	 * @param callerName  A symbolic name given to the caller of this method, to
240
	 *                    show it in the log if the key was not found
241
	 * @param log         Determines whether log a key failure or not
242
	 * @return            an String with the message associated with the provided key,
243
	 *                    or null if the key is not in the dictionary.
244
	 */
245
	public static String getText(String key, String callerName, boolean log) {
246
		if (key==null) {
247
			return null;
248
		}
249
		for (int numLocale=0; numLocale<localeResources.size(); numLocale++) {
250
			// try to get the translation for any of the languagues in the preferred languages list
251
			String translation = ((Properties)localeResources.get(numLocale)).getProperty(key);
252
			if (translation!=null && !translation.equals("")) {
253
				return translation;
254
			}
255
		}
256
                addNotTranslatedKey(key, callerName, log);
257
		return null;
258
	}
259

  
260
	public static String getText(String key, String[] arguments, String callerName, boolean log) {
261
		String translation = getText(key, callerName, log);
262
		if (translation!=null) {
263
			try {
264
				translation = MessageFormat.format(translation, arguments);
265
			}
266
			catch (IllegalFormatException ex) {
267
				if (log) {
268
					logger.error(callerName+" -- Error formating key: "+key+" -- "+translation);
269
				}
270
			}
271
		}
272
		return translation;
273
	}
274

  
275
	/**
276
	 * <p>Adds an additional family of resource files containing some translations.
277
	 * A family is a group of files with a common baseName.
278
	 * The file must be an iso-8859-1 encoded file, which can contain any unicode
279
	 * character using unicode escaped sequences, and following the syntax:
280
	 * <code>key1=value1
281
	 * key2=value2</code>
282
	 * where 'key1' is the key used to identify the string and must not
283
	 * contain the '=' symbol, and 'value1' is the associated translation.</p>
284
	 * <p<For example:</p>
285
	 * <code>cancel=Cancelar
286
	 * accept=Aceptar</code>
287
	 * <p>Only one pair key-value is allowed per line.</p>
288
	 *
289
	 * <p>The actual name of the resource file to load is determined using the rules
290
	 * explained in the class java.util.ResourceBundle. Summarizing, for each language
291
	 * in the specified preferred locales list it will try to load a file with
292
	 *  the following structure: <code>family_locale.properties</code></p>
293
	 *
294
	 * <p>For example, if the preferred locales list contains {"fr", "es", "en"}, and
295
	 * the family name is "text", it will try to load the files "text_fr.properties",
296
	 * "text_es.properties" and finally "text_en.properties".</p>
297
	 *
298
	 * <p>Locales might be more specific, such us "es_AR"  (meaning Spanish from Argentina)
299
	 * or "es_AR_linux" (meaning Linux system preferring Spanish from Argentina). In the
300
	 * later case, it will try to load "text_es_AR_linux.properties", then
301
	 * "text_es_AR.properties" if the former fails, and finally "text_es.properties".</p>
302
	 *
303
	 * <p>The directory used to locate the resource file is determining by using the
304
	 * getResource method from the provided ClassLoader.</p>
305
	 *
306
	 * @param family    The family name (or base name) which is used to search
307
	 *                  actual properties files.
308
	 * @param loader    A ClassLoader which is able to find a property file matching
309
	 * 					the specified family name and the preferred locales
310
	 * @see             <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
311
	 */
312
	public static void addResourceFamily(String family, ClassLoader loader) {
313
		addResourceFamily(family, loader, "");
314
	}
315

  
316
	/**
317
	 * <p>Adds an additional family of resource files containing some translations.
318
	 * The search path to locate the files is provided by the dirList parameter.</p>
319
	 *
320
	 * <p>See {@link addResourceFamily(String, ClassLoader)} for a discussion about the
321
	 * format of the property files and the way to determine the candidat files
322
	 * to load. Note that those methods are different in the way to locate the
323
	 * candidat files. This method searches in the provided paths (<code>dirList</code>
324
	 * parameter), while the referred method searches using the getResource method
325
	 * of the provided ClassLoader.</p>
326
	 *
327
	 * @param family    The family name (or base name) which is used to search
328
	 *                  actual properties files.
329
	 * @param dirList   A list of search paths to locate the property files
330
	 * @throws MalformedURLException
331
	 * @see             <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
332
	 */
333
	public static void addResourceFamily(String family, File[] dirList) throws MalformedURLException{
334
		// use our own classloader
335
		URL[] urls = new URL[dirList.length];
336

  
337
			int i;
338
			for (i=0; i<urls.length; i++) {
339
				urls[i] = dirList[i].toURL();
340
			}
341

  
342
		ClassLoader loader = new MessagesClassLoader(urls);
343
		addResourceFamily(family, loader, "");
344
	}
345

  
346
	/**
347
	 * <p>Adds an additional family of resource files containing some translations.
348
	 * The search path to locate the files is provided by the dir parameter.</p>
349
	 *
350
	 * <p>See {@link addResourceFamily(String, ClassLoader)} for a discussion about the
351
	 * format of the property files and the way to determine the candidat files
352
	 * to load. Note that those methods are different in the way to locate the
353
	 * candidat files. This method searches in the provided path (<code>dir</code>
354
	 * parameter), while the referred method searches using the getResource method
355
	 * of the provided ClassLoader.</p>
356
	 *
357
	 * @param family    The family name (or base name) which is used to search
358
	 *                  actual properties files.
359
	 * @param dir       The search path to locate the property files
360
	 * @throws MalformedURLException
361
	 * @see             <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
362
	 */
363
	public static void addResourceFamily(String family, File dir) throws MalformedURLException{
364
		// use our own classloader
365
		URL[] urls = new URL[1];
366
		urls[0] = dir.toURL();
367
		ClassLoader loader = new MessagesClassLoader(urls);
368
		addResourceFamily(family, loader, "");
369
	}
370

  
371

  
372
	/**
373
	 * <p>Adds an additional family of resource files containing some translations.
374
	 * The search path is determined by the getResource method from the
375
	 * provided ClassLoader.</p>
376
	 *
377
	 * <p>This method is identical to {@link addResourceFamily(String, ClassLoader)},
378
	 * except that it adds a <pode>callerName</code> parameter to show in the log.</p>
379
	 *
380
	 * <p>See {@link addResourceFamily(String, ClassLoader)} for a discussion about the
381
	 * format of the property files andthe way to determine the candidat files
382
	 * to load.</p>
383
	 *
384
	 * @param family      The family name (or base name) which is used to search
385
	 *                    actual properties files.
386
	 * @param loader      A ClassLoader which is able to find a property file matching
387
	 * 					  the specified family name and the preferred locales
388
	 * @param callerName  A symbolic name given to the caller of this method, to
389
	 *                    show it in the log if there is an error
390
	 * @see               <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
391
	 */
392
	public static void addResourceFamily(String family, ClassLoader loader, String callerName) {
393
//		String currentKey;
394
//		Enumeration keys;
395
		Locale lang;
396
//		Properties properties;
397
		Properties translations;
398
		int totalLocales = preferredLocales.size();
399

  
400
		if (totalLocales == 0) {
401
			// if it's empty, warn about that
402
			logger.warn("There is not preferred languages list. Maybe the Messages class was not initialized");
403
		}
404

  
405
                familyDescriptors.add( new FamilyDescriptor(family,loader,callerName));
406
                
407
		resourceFamilies.add(family);
408
		classLoaders.add(loader);
409

  
410
		for (int numLocale=0; numLocale<totalLocales; numLocale++) { // for each language
411
//			properties =  new Properties();
412

  
413
			lang = (Locale) preferredLocales.get(numLocale);
414
			translations = (Properties) localeResources.get(numLocale);
415

  
416
			addResourceFamily(lang, translations, family, loader, callerName);
417
		}
418
	}
419
        
420
	private static void addResourceFamily(Locale lang, Properties translations,
421
			String family, ClassLoader loader, String callerName) {
422
                logger.debug("addResourceFamily "+lang.toString()+", "+family+", "+loader.toString());
423
                
424
		Properties properties = new Properties();
425
		String langCode = lang.toString();
426
		String resource = family.replace('.', '/') + "_" + langCode + ".properties";
427
                URL resourceURL = loader.getResource(resource);
428
		InputStream is = loader.getResourceAsStream(resource);
429
		if( is==null && langCode.contains("_") ) {
430
			try {
431
				langCode = langCode.split("_")[0];
432
				resource = family.replace('.', '/') + "_" + langCode + ".properties";
433
                                resourceURL = loader.getResource(resource);
434
				is = loader.getResourceAsStream(resource);
435
				if( is==null ) {
436
					resource = family.replace('.', '/') +  ".properties";
437
                                        resourceURL = loader.getResource(resource);
438
					is = loader.getResourceAsStream(resource);
439
				}
440
			} catch(Exception ex) {
441
				// Do nothing, is are null and are handled later
442
			}
443
		}
444
		if (is != null) {
445
			try {
446
				properties.load(is);
447
			} catch (IOException e) {
448
			}
449
		} else if (lang.equals(baseLocale)) {
450
			// try also "text.properties" for the base language
451
			is = loader.getResourceAsStream(family.replace('.', '/')
452
					+ ".properties");
453

  
454

  
455
			if (is != null) {
456
				try {
457
					properties.load(is);
458
				} catch (IOException e) {
459
				}
460
			}
461

  
462
		}
463
                if( resourceURL!=null && logger.isDebugEnabled() ) {
464
                    logger.debug("Load resources from '"+resourceURL.toString()+"' with classloader {"+loader.toString()+"}.");
465
                }
466
		Enumeration keys = properties.keys();
467
		while (keys.hasMoreElements()) {
468
			String currentKey = (String) keys.nextElement();
469
			if (!translations.containsKey(currentKey)) {
470
				translations.put(currentKey, properties.getProperty(currentKey));
471
			}
472
		}
473

  
474
	}
475

  
476
	/**
477
	 * <p>Adds an additional family of resource files containing some translations.</p>
478
	 *
479
	 * <p>This method is identical to {@link addResourceFamily(String, ClassLoader, String)},
480
	 * except that it uses the caller's class loader.</p>
481
	 *
482
	 * <p>See {@link addResourceFamily(String, ClassLoader)} for a discussion about the
483
	 * format of the property files and the way to determine the candidat files
484
	 * to load.</p>
485
	 *
486
	 * @param family      The family name (or base name) which is used to search
487
	 *                    actual properties files.
488
	 * @param callerName  A symbolic name given to the caller of this method, to
489
	 *                    show it in the log if there is an error. This is only used
490
	 *                    to show
491
	 *                    something meaningful in the log, so you can use any string
492
	 * @see               <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
493
	 */
494
	public static void addResourceFamily(String family, String callerName) {
495
		addResourceFamily(family, Messages.class.getClassLoader(), callerName);
496
	}
497

  
498

  
499
	/**
500
	 * Returns an ArrayList containing the ordered list of prefered Locales
501
	 * Each element of the ArrayList is a Locale object.
502
	 *
503
	 * @return an ArrayList containing the ordered list of prefered Locales
504
	 * Each element of the ArrayList is a Locale object.
505
	 */
506
	public static ArrayList getPreferredLocales() {
507
		return preferredLocales;
508
	}
509

  
510
	/**
511
	 * <p>Sets the ordered list of preferred locales.
512
	 * Each element of the ArrayList is a Locale object.</p>
513
	 *
514
	 * <p>Note that calling this method does not load any translation, it just
515
	 * adds the language to the preferred locales list, so this method must
516
	 * be always called before the translations are loaded using
517
	 * the addResourceFamily() methods.</p>
518
	 *
519
	 * <p>It there was any language in the preferred locale list, the language
520
	 * and its associated translations are deleted.</p>
521
	 *
522
	 *
523
	 * @param preferredLocales an ArrayList containing Locale objects.
524
	 * The ArrayList represents an ordered list of preferred locales
525
	 */
526
	public static void setPreferredLocales(ArrayList preferredLocalesList) {
527
                logger.info("setPreferredLocales "+preferredLocalesList.toString());
528
		// delete all existing locales
529
		Iterator oldLocales = preferredLocales.iterator();
530
		while (oldLocales.hasNext()) {
531
			removeLocale((Locale) oldLocales.next());
532
		}
533

  
534
		// add the new locales now
535
		for (int numLocale=0; numLocale < preferredLocalesList.size(); numLocale++) {
536
			addLocale((Locale) preferredLocalesList.get(numLocale));
537
		}
538
	}
539

  
540
        public static Locale getCurrentLocale() {
541
            return currentLocale;
542
        }
543

  
544
        /**
545
         * 
546
         * @deprecated  use setCurrentLocale(Locale locale, Locale alternatives[]) or LocaleManager.setCurrentLocale
547
         */
548
        public static void setCurrentLocale(Locale locale) {
549
            Locale alternatives[] = null;
550

  
551
            String localeStr = locale.getLanguage();
552
            if ( localeStr.equals("es") || 
553
                 localeStr.equals("ca") ||
554
                 localeStr.equals("gl") || 
555
                 localeStr.equals("eu") ||
556
                 localeStr.equals("vl") ) {
557
                alternatives = new Locale[2];
558
                alternatives[0] = new Locale("es");
559
                alternatives[1] = new Locale("en");
560
            } else {
561
                // prefer English for the rest
562
                alternatives = new Locale[2];
563
                alternatives[0] = new Locale("en");
564
                alternatives[1] = new Locale("es");
565
            }
566
            setCurrentLocale(locale, alternatives);
567
        }
568
        
569
        public static void setCurrentLocale(Locale locale, Locale alternatives[]) {
570
            logger.info("setCurrentLocale "+locale.toString());
571
            
572
            resourceFamilies = new HashSet();
573
            classLoaders = new HashSet();
574
            localeResources = new ArrayList();
575
            preferredLocales = new ArrayList();
576
            notTranslatedKeys = new HashSet();            
577
            
578
            addLocale(locale);
579
            for( int i=0 ; i<alternatives.length; i++ ) {
580
                addLocale(alternatives[i]);
581
            }
582
            for( int curlocale=0; curlocale<preferredLocales.size(); curlocale++) {
583
                for( int curfamily=0; curfamily<familyDescriptors.size(); curfamily++) {
584
                     FamilyDescriptor family = (FamilyDescriptor) familyDescriptors.get(curfamily);
585
                     addResourceFamily(
586
                             (Locale) preferredLocales.get(curlocale),
587
                             (Properties) localeResources.get(curlocale),
588
                             family.family,
589
                             family.loader,
590
                             family.callerName);
591
                }
592
            }
593
            currentLocale = locale;
594
            Locale.setDefault(locale);
595
        }
596

  
597
	/**
598
	 * Adds a Locale at the end of the ordered list of preferred locales.
599
	 * Note that calling this method does not load any translation, it just
600
	 * adds the language to the preferred locales list, so this method must
601
	 * be always called before the translations are loaded using
602
	 * the addResourceFamily() methods.
603
	 *
604
	 * @param lang   A Locale object specifying the locale to add
605
	 */
606
	public static void addLocale(Locale lang) {
607
		if (!preferredLocales.contains(lang)) { // avoid duplicates
608
                    logger.info("addLocale "+lang.toString());
609
                    preferredLocales.add(lang); // add the lang to the ordered list of preferred locales
610
                    Properties dict = new Properties();
611
                    localeResources.add(dict); // add a hashmap which will contain the translation for this language
612
		}
613
	}
614

  
615
	/**
616
	 * Removes the specified Locale from the list of preferred locales and the
617
	 * translations associated with this locale.
618
	 *
619
	 * @param lang   A Locale object specifying the locale to remove
620
	 * @return       True if the locale was in the preferred locales list, false otherwise
621
	 */
622
	public static boolean removeLocale(Locale lang) {
623
		int numLocale = preferredLocales.indexOf(lang);
624
		if (numLocale!=-1) { // we found the locale in the list
625
			try {
626
				preferredLocales.remove(numLocale);
627
				localeResources.remove(numLocale);
628
			}
629
			catch (IndexOutOfBoundsException ex) {
630
				logger.warn(_CLASSNAME + "." + "removeLocale: " + ex.getLocalizedMessage(), ex);
631
			}
632
			return true;
633
		}
634
		return false;
635
	}
636

  
637
	/**
638
	 * Cleans the translation tables (removes all the translations from memory).
639
	 */
640
	public static void removeResources() {
641
		for (int numLocale=0; numLocale<localeResources.size(); numLocale++) {
642
			((Properties)localeResources.get(numLocale)).clear();
643
		}
644
	}
645

  
646
	/**
647
	 * The number of translation keys which have been loaded till now
648
	 * (In other words: the number of available translation strings).
649
	 *
650
	 * @param lang The language for which we want to know the number of translation keys
651
	 * return The number of translation keys for the provided language.
652
	 */
653
	protected static int size(Locale lang) {
654
		int numLocale = preferredLocales.indexOf(lang);
655
		if (numLocale!=-1) {
656
			return ((Properties)localeResources.get(numLocale)).size();
657
		};
658
		return 0;
659
	}
660

  
661
	protected static Set keySet(Locale lang) {
662
		int numLocale = preferredLocales.indexOf(lang);
663
		if (numLocale!=-1) {
664
			return ((Properties)localeResources.get(numLocale)).keySet();
665
		} else {
666
			return null;
667
		}
668
	}
669

  
670
	/**
671
	 * Checks if some locale has been added to the preferred locales
672
	 * list, which is necessary before loading any translation because
673
	 * only the translations for the preferred locales are loaded.
674
	 *
675
	 * @return
676
	 */
677
	public static boolean hasLocales() {
678
		return preferredLocales.size()>0;
679
	}
680

  
681
	/**
682
	 * Gets the base language, the language considered the origin of
683
	 * translations, which will be (possibly) stored in a property
684
	 * file without language suffix
685
	 * (ie: text.properties instead of text_es.properties).
686
	 */
687
	public static String getBaseLanguage() {
688
		return baseLanguage;
689
	}
690

  
691
	/**
692
	 * Sets the base language, the language considered the origin of
693
	 * translations, which will be (possibly)
694
	 * stored in a property file without language suffix
695
	 * (ie: text.properties instead of text_es.properties).
696
	 *
697
	 * @param lang The base language to be set
698
	 */
699
	public static void setBaseLanguage(String lang) {
700
		baseLanguage = lang;
701
		baseLocale = new Locale(baseLanguage);
702
	}
703

  
704
	/*
705
	 * Searches the subdirectories of the provided directory, finding
706
	 * all the translation files, and constructing a list of available translations.
707
	 * It reports different country codes or variants, if available.
708
	 * For example, if there is an en_US translation and an en_GB translation, both
709
	 * locales will be present in the Vector.
710
	 *
711
	 * @return
712
	 */
713

  
714
	/**
715
	 *
716
	 * @return A Vector containing the available locales. Each element is a Locale object
717
	 */
718
	/*public static Vector getAvailableLocales() {
719
		return _availableLocales;
720
	}*/
721

  
722
	/**
723
	 *
724
	 * @return A Vector containing the available languages. Each element is an String object
725
	 */
726
	/*public static Vector getAvailableLanguages() {
727
		Vector availableLanguages = new Vector();
728
		Locale lang;
729
		Enumeration locales = _availableLocales.elements();
730
		while (locales.hasMoreElements()) {
731
			lang = (Locale) locales.nextElement();
732
			availableLanguages.add(lang.getLanguage());
733
		}
734
		return availableLanguages;
735
	}*/
736

  
737
	public static Properties getAllTexts(Locale lang) {
738
		Properties texts = new Properties();
739
		getAllTexts(lang, null, texts);
740
		for (Iterator iterator = classLoaders.iterator(); iterator.hasNext();) {
741
			getAllTexts(lang, (ClassLoader) iterator.next(), texts);
742
		}
743
		return texts;
744
	}
745

  
746
	private static void getAllTexts(Locale lang, ClassLoader classLoader,
747
			Properties texts) {
748
		ClassLoader loader = classLoader == null ? Messages.class
749
				.getClassLoader() : classLoader;
750

  
751
		for (Iterator iterator = resourceFamilies.iterator(); iterator
752
				.hasNext();) {
753
			String family = (String) iterator.next();
754
			addResourceFamily(lang, texts, family, loader,
755
					"Messages.getAllTexts");
756
		}
757
	}
758

  
759
        
760
        public static Properties getTranslations(Locale locale) {
761
		Properties translations = new Properties();
762
                for( int curfamily=0; curfamily<familyDescriptors.size(); curfamily++) {
763
                     FamilyDescriptor family = (FamilyDescriptor) familyDescriptors.get(curfamily);
764
                     addResourceFamily(
765
                             locale,
766
                             translations,
767
                             family.family,
768
                             family.loader,
769
                             family.callerName);
770
                }
771
                return translations;
772
        }
773

  
774
        private static void addNotTranslatedKey(String key, String callerName, boolean log) {
775
            if (!notTranslatedKeys.contains(key)) {
776
                if( log ) {
777
                    logger.info("[" + callerName + "] Cannot find translation for key '" + key + "'.");
778
                }
779
                notTranslatedKeys.add(key);
780
            }
781
        }
782
        
783
        public static List getNotTranslatedKeys() {
784
            List l = new ArrayList(notTranslatedKeys);
785
            return l;
786
        }
787
}
0 788

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/MessagesLibrary.java
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
package org.gvsig.i18n;
25

  
26
import org.gvsig.i18n.tools.impl.DefaultI18Manager;
27
import org.gvsig.tools.ToolsLibrary;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.library.AbstractLibrary;
30
import org.gvsig.tools.library.LibraryException;
31

  
32
/**
33
 * This library is in charge of providing a richer translation manager than the
34
 * one used by default.
35
 * 
36
 * 
37
 * @author christian
38
 * 
39
 */
40
public class MessagesLibrary extends AbstractLibrary {
41

  
42
	public void doRegistration() {
43
		super.doRegistration();
44
		this.registerAsServiceOf(ToolsLibrary.class);
45
		require(ToolsLocator.class);
46
	}
47

  
48
	protected void doInitialize() throws LibraryException {
49
		ToolsLocator.registerI18nManager(DefaultI18Manager.class);
50
	}
51

  
52
	protected void doPostInitialize() throws LibraryException {
53
        // Nothing to do
54
	}
55

  
56
}
0 57

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/package.html
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
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 3
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
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
28
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
29
<head>
30
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
31
<title>org.gvsig.i18n package</title>
32
</head>
33
<body>
34
<p>Provides classes which offer some methods to provide internationalization services
35
to other projects. Currently, it only consist on the Messages class and the auxiliary
36
MessagesClassLoader class.</p>
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/java/org/gvsig/i18n/templates/MessagesTemplate.java
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

  
26
package org.gvsig.i18n.templates;
27

  
28
import java.util.Locale;
29

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

  
75
}
0 76

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Accepter
4
Las_traducciones_no_pudieron_ser_cargadas=Les traductions ne peuvent pas \u00eatre charg\u00e9es.
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=Impossible de trouver la liste des langues pr\u00e9f\u00e9r\u00e9es. Vous avez peut-\u00eatre oubli\u00e9 d'installer la classe.
7
No_se_encontro_la_traduccion_para=Impossible de trouver les traductions pour
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_de.properties
1
#Translations for language [de]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=OK
4
Las_traducciones_no_pudieron_ser_cargadas=
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=
7
No_se_encontro_la_traduccion_para=Konnte \u00dcbersetzung nicht finden f\u00fcr\:
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Ados
4
Las_traducciones_no_pudieron_ser_cargadas=Itzulpenak ezin izan dira kargatu
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=\=Ez da hobetsitako hizkuntzen zerrenda aurkitu. Agian klasea hasieratzea ahaztu zaizu
7
No_se_encontro_la_traduccion_para=Ez da itzulpenik aurkitu honetarako\:
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
aceptar=Accetta
4
Las_traducciones_no_pudieron_ser_cargadas=
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=
7
No_se_encontro_la_traduccion_para=Non si \u00e9 incontrata la traduzione per
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Aceptar
4
Las_traducciones_no_pudieron_ser_cargadas=Las traducciones no pudieron ser cargadas
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=No hay lista de idiomas preferidos. Quiza olvido inicializar la clase
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=No hay lista de idiomas preferidos. Quiz\u00e1 olvid\u00f3 inicializar la clase.
7
No_se_encontro_la_traduccion_para=No se encontr\u00f3 la traducci\u00f3n para
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.i18n.MessagesLibrary
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_en.properties
1
#Translations for language [en]
2
#Wed Nov 08 12:31:46 CET 2006
3
=\=\=\=\=\=\=
4
<<<<<<<=text_en.properties
5
>>>>>>>=1.6
6
aceptar=Accept
7
Las_traducciones_no_pudieron_ser_cargadas=Translations couldn't be loaded
8
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=There is no list of favorite languages probably you forgot initialice the class
9
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=There is not preferred languages list. Maybe the Messages class was not initiated
10
No_se_encontro_la_traduccion_para=Cannot find translation for
0 11

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Aceptar
4
Las_traducciones_no_pudieron_ser_cargadas=As traducci\u00f3ns non se puideron cargar
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=Non se atopou a lista de idiomas preferidos.Quiz\u00e1s non se lembrou de inicializar a clase
7
No_se_encontro_la_traduccion_para=Non se atopou a traducci\u00f3n para
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Acceptar
4
Las_traducciones_no_pudieron_ser_cargadas=Les traduccions no s'han pogut carregar
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=No s'ha trobat la llista d'idiomes preferits. Potser ha oblidat inicialitzar la classe
7
No_se_encontro_la_traduccion_para=No s'ha trobat la traducci\u00f3 per a
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Aceitar
4
Las_traducciones_no_pudieron_ser_cargadas=
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=
7
No_se_encontro_la_traduccion_para=N\u00e3o se encontrou a tradu\u00e7\u00e3o de
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/main/resources/text_cs.properties
1
#Translations for language [cs]
2
#Mon Oct 30 09:38:21 CET 2006
3
aceptar=Budi\u017e
4
Las_traducciones_no_pudieron_ser_cargadas=
5
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=
6
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=
7
No_se_encontro_la_traduccion_para=Nelze nal\u00e9zt p\u0159eklad pro
0 8

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/test/java/org/gvsig/i18n/dataset1/text.properties
1
#text.properties
2
aceptar=Aceptar
3
cancelar=Cancelar
4
Cascada=Cascada
5
cascada_enable=Debe haber al menos una ventana abierta
0 6

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/test/java/org/gvsig/i18n/dataset1/text_en.properties
1
#text_en.properties
2
aceptar=OK
3
cancelar=Cancel
4
Cascada=Cascade
5
ventana=Window
6
otro=other
0 7

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/test/java/org/gvsig/i18n/dataset1/text_fr.properties
1
#text_fr.properties
2
aceptar=Accepter
3
Cascada=Cascade
4
Configurar=Configurer
0 5

  
tags/org.gvsig.desktop-2.0.86/org.gvsig.desktop.compat.cdc/org.gvsig.i18n/src/test/java/org/gvsig/i18n/TestMessages.java
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
package org.gvsig.i18n;
25

  
26
import java.io.File;
27
import java.net.MalformedURLException;
28
import java.util.ArrayList;
29
import java.util.Locale;
30

  
31
import junit.framework.TestCase;
32

  
33
/**
34
 * @author cesar
35
 *
36
 */
37
public class TestMessages extends TestCase {
38

  
39
	/*
40
	 * @see TestCase#setUp()
41
	 */
42
	protected void setUp() throws Exception {
43
		super.setUp();
44
	}
45

  
46
	/*
47
	 * @see TestCase#tearDown()
48
	 */
49
	protected void tearDown() throws Exception {
50
		super.tearDown();
51
	}
52
	
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff