Revision 36494
tags/v_1_12_0_Build_1402/libInternationalization/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|
2 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>libInternationalization</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<version>1.9-SNAPSHOT</version> |
|
9 |
<name>libInternationalization</name> |
|
10 |
<url>http://gvsig.org</url> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>gvsig-library-base-pom</artifactId> |
|
14 |
<version>1.9-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
<properties> |
|
17 |
<build-dir>${basedir}/../build</build-dir> |
|
18 |
</properties> |
|
19 |
<dependencies> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig.legacy</groupId> |
|
22 |
<artifactId>kxml2</artifactId> |
|
23 |
<version>gvsig</version> |
|
24 |
</dependency> |
|
25 |
</dependencies> |
|
26 |
<build> |
|
27 |
<sourceDirectory>src</sourceDirectory> |
|
28 |
<testSourceDirectory>src-test</testSourceDirectory> |
|
29 |
</build> |
|
30 |
</project> |
tags/v_1_12_0_Build_1402/libInternationalization/.cvsignore | ||
---|---|---|
1 |
bin |
|
2 |
bin-test |
|
3 |
bin-utils |
|
4 |
doc |
|
0 | 5 |
tags/v_1_12_0_Build_1402/libInternationalization/build.xml | ||
---|---|---|
1 |
<project name="i18n (Internationalization)" default="dist" basedir="."> |
|
2 |
<description> |
|
3 |
Construye el jar de la biblioteca gvsig-i18n (libInternationalization) |
|
4 |
</description> |
|
5 |
<!-- set global properties for this build --> |
|
6 |
<property name="src" location="src"/> |
|
7 |
<property name="src-test" location="src-test"/> |
|
8 |
<property name="build" location="bin"/> |
|
9 |
<property name="build-test" location="bin-test"/> |
|
10 |
<property name="andamiLibs" location="../_fwAndami/lib"/> |
|
11 |
<property name="dist" location="dist"/> |
|
12 |
<property name="lib" location="lib"/> |
|
13 |
<property name="plugin" value="org.gvsig.i18n"/> |
|
14 |
<property name="jarName" value="gvsig-i18n"/> |
|
15 |
<property name="targetDir" location="../_fwAndami/lib"/> |
|
16 |
<property name="build-doc" value="doc"/> |
|
17 |
<!--<property name="compile-classpath" value="${andamiLibs}/log4j-1.2.8.jar"/>--> |
|
18 |
<import file="../binaries/ant/utilities.xml"/> |
|
19 |
|
|
20 |
<target name="init"> |
|
21 |
<!-- Create the time stamp --> |
|
22 |
<tstamp /> |
|
23 |
<echo> |
|
24 |
Compiling ${ant.project.name}...</echo> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="build-doc" depends="" description="Genera la documentación"> |
|
28 |
<javadoc |
|
29 |
packagenames="org.gvsig.i18n.*" |
|
30 |
sourcepath="src" |
|
31 |
defaultexcludes="yes" |
|
32 |
destdir="${build-doc}/org.gvsig.i18n" |
|
33 |
windowtitle="libInternationalization API"> |
|
34 |
</javadoc> |
|
35 |
</target> |
|
36 |
|
|
37 |
<target name="dist" |
|
38 |
description="generate the distribution" depends="copy-data-files,create-jar,move-to-andami"> |
|
39 |
</target> |
|
40 |
|
|
41 |
<target name="batch-build" |
|
42 |
description="compile the sources, create the jar file" |
|
43 |
depends="init,compile,copy-data-files,create-jar,move-to-andami"> |
|
44 |
</target> |
|
45 |
|
|
46 |
<target name="compile" description="compile the source"> |
|
47 |
<!-- Compile the Java code from ${src} to ${build} --> |
|
48 |
<mkdir dir="${build}" /> |
|
49 |
<loadEclipseClasspath project="${basedir}"/> |
|
50 |
<gvSIG-javac |
|
51 |
classpath="${eclipseClasspath}" |
|
52 |
/> |
|
53 |
|
|
54 |
<!--<javac srcdir="${src}" |
|
55 |
destdir="${build}" |
|
56 |
source="1.4" |
|
57 |
target="1.4" |
|
58 |
classpath="${compile-classpath}" |
|
59 |
debug="${debug}" |
|
60 |
debuglevel="${debuglevel}" |
|
61 |
excludes="**/Tests/*.java" />--> |
|
62 |
</target> |
|
63 |
|
|
64 |
<target name="copy-data-files"> |
|
65 |
<mkdir dir="config"/> |
|
66 |
<copy todir="${build}/org/gvsig/i18n/resources/translations"> |
|
67 |
<fileset dir="config" includes="*" /> |
|
68 |
</copy> |
|
69 |
</target> |
|
70 |
|
|
71 |
<target name="create-jar" description="Crea el jar de la aplicacion"> |
|
72 |
<mkdir dir="${dist}"/> |
|
73 |
<jar jarfile="${dist}/${jarName}.jar" basedir="${build}"/> |
|
74 |
</target> |
|
75 |
|
|
76 |
<target name="move-to-andami" description="Move jars and required libraries to andami"> |
|
77 |
<copy file="dist/${jarName}.jar" todir="${lib}"/> |
|
78 |
<move file="dist/${jarName}.jar" todir="${targetDir}"/> |
|
79 |
</target> |
|
80 |
|
|
81 |
<target name="clean" |
|
82 |
description="clean up" > |
|
83 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
84 |
<delete dir="${build}"/> |
|
85 |
<delete dir="${dist}"/> |
|
86 |
</target> |
|
87 |
|
|
88 |
<target name="run-tests" depends="batch-build,compile-tests"> |
|
89 |
<antcall target="generic-run-tests"> |
|
90 |
<param name="TestSuite.Name" value="org.gvsig.i18n.AllTests"/> |
|
91 |
</antcall> |
|
92 |
</target> |
|
93 |
</project> |
|
0 | 94 |
tags/v_1_12_0_Build_1402/libInternationalization/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" output="bin-utils" path="src-utils"/> |
|
5 |
<classpathentry kind="src" output="bin-test" path="src-test"/> |
|
6 |
<classpathentry kind="src" path="src-utils-test"/> |
|
7 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
8 |
<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/> |
|
9 |
<classpathentry kind="lib" path="/_fwAndami/lib/kxml2.jar"/> |
|
10 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.14.jar"/> |
|
11 |
<classpathentry kind="output" path="bin"/> |
|
12 |
</classpath> |
|
0 | 13 |
tags/v_1_12_0_Build_1402/libInternationalization/src-utils-test/org/gvsig/i18n/utils/TestProperties.java | ||
---|---|---|
1 |
package org.gvsig.i18n.utils; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileInputStream; |
|
5 |
import java.io.FileNotFoundException; |
|
6 |
import java.io.FileOutputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStream; |
|
9 |
import java.io.OutputStream; |
|
10 |
|
|
11 |
import junit.framework.TestCase; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author cesar |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class TestProperties extends TestCase { |
|
18 |
static final String fileName = "TestProperties-file"; |
|
19 |
InputStream is; |
|
20 |
OutputStream os; |
|
21 |
|
|
22 |
public void initOutputStream() { |
|
23 |
try { |
|
24 |
os = new FileOutputStream(fileName); |
|
25 |
} catch (FileNotFoundException e) { |
|
26 |
TestCase.fail(e.getLocalizedMessage()); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
public void discardOutputStream() { |
|
31 |
try { |
|
32 |
os.close(); |
|
33 |
File file = new File(fileName); |
|
34 |
file.delete(); |
|
35 |
} catch (IOException e) { |
|
36 |
TestCase.fail(e.getLocalizedMessage()); |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
public void initInputStream() { |
|
41 |
try { |
|
42 |
is = new FileInputStream(fileName); |
|
43 |
} catch (FileNotFoundException e) { |
|
44 |
TestCase.fail(e.getLocalizedMessage()); |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public void discardInputStream() { |
|
49 |
try { |
|
50 |
is.close(); |
|
51 |
} catch (IOException e) { |
|
52 |
TestCase.fail(e.getLocalizedMessage()); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
public void testOrderedPropertiesBasic() { |
|
57 |
// write file |
|
58 |
OrderedProperties props1 = new OrderedProperties(); |
|
59 |
props1.setProperty("prueba", "hola"); |
|
60 |
props1.setProperty("prueba2", "holas"); |
|
61 |
props1.setProperty("abrir", "cerrar"); |
|
62 |
props1.setProperty("puerta", "hembrilla"); |
|
63 |
props1.setProperty("12libros", "quijote"); |
|
64 |
props1.setProperty("ca?uto", "\u20acuropeo"); |
|
65 |
props1.setProperty("confli=cto", "amigo"); |
|
66 |
props1.setProperty(" confli = :cto mayor ", " peque?o conflicto"); |
|
67 |
initOutputStream(); |
|
68 |
try { |
|
69 |
props1.store(os, "header"); |
|
70 |
} catch (IOException e) { |
|
71 |
TestCase.fail(e.getLocalizedMessage()); |
|
72 |
} |
|
73 |
|
|
74 |
// read file |
|
75 |
OrderedProperties props2 = new OrderedProperties(); |
|
76 |
initInputStream(); |
|
77 |
try { |
|
78 |
props2.load(is); |
|
79 |
} catch (IOException e) { |
|
80 |
TestCase.fail(e.getLocalizedMessage()); |
|
81 |
} |
|
82 |
TestCase.assertEquals("\u20acuropeo", props2.getProperty("ca?uto")); |
|
83 |
TestCase.assertEquals("amigo", props2.getProperty("confli=cto")); |
|
84 |
TestCase.assertEquals(" peque?o conflicto", props2.getProperty(" confli = :cto mayor ")); |
|
85 |
TestCase.assertEquals("hola", props2.getProperty("prueba")); |
|
86 |
TestCase.assertEquals("holas", props2.getProperty("prueba2")); |
|
87 |
TestCase.assertEquals("cerrar", props2.getProperty("abrir")); |
|
88 |
TestCase.assertEquals("hembrilla", props2.getProperty("puerta")); |
|
89 |
TestCase.assertEquals("quijote", props2.getProperty("12libros")); |
|
90 |
discardInputStream(); |
|
91 |
discardOutputStream(); |
|
92 |
} |
|
93 |
|
|
94 |
|
|
95 |
public void testOrderedProperties() { |
|
96 |
// write file |
|
97 |
OrderedProperties props1 = new OrderedProperties(); |
|
98 |
props1.setProperty("prueba", "hola"); |
|
99 |
props1.setProperty("prueba2", "holas"); |
|
100 |
props1.setProperty("ca?uto", "\u20acuropeo"); |
|
101 |
props1.setProperty("confli=cto", "amigo"); |
|
102 |
props1.setProperty(" conflis = :cto mayor ", " peque?o conflicto"); |
|
103 |
props1.setProperty("abrir", "cerrar"); |
|
104 |
props1.setProperty("puerta", "hembrilla"); |
|
105 |
props1.setProperty("12libros", "quijote"); |
|
106 |
initOutputStream(); |
|
107 |
try { |
|
108 |
props1.store(os, "header", "8859_15"); |
|
109 |
} catch (IOException e) { |
|
110 |
TestCase.fail(e.getLocalizedMessage()); |
|
111 |
} |
|
112 |
|
|
113 |
// read file |
|
114 |
OrderedProperties props2 = new OrderedProperties(); |
|
115 |
initInputStream(); |
|
116 |
try { |
|
117 |
props2.load(is, "8859_15"); |
|
118 |
} catch (IOException e) { |
|
119 |
TestCase.fail(e.getLocalizedMessage()); |
|
120 |
} |
|
121 |
// estos deber?an salir igual |
|
122 |
TestCase.assertEquals("hola", props2.getProperty("prueba")); |
|
123 |
TestCase.assertEquals("holas", props2.getProperty("prueba2")); |
|
124 |
TestCase.assertEquals("cerrar", props2.getProperty("abrir")); |
|
125 |
TestCase.assertEquals("hembrilla", props2.getProperty("puerta")); |
|
126 |
TestCase.assertEquals("quijote", props2.getProperty("12libros")); |
|
127 |
// con estos en cambio no obtenemos los mismos valores que escribimos anteriormente. Es normal, porque incluimos |
|
128 |
// caracteres especiales como ":" y "=". Para manejarlos correctamente necesitamos usas los m?todos load/store |
|
129 |
// sin encoding, los cuales s? escapan los caracteres especiales |
|
130 |
TestCase.assertEquals("\u20acuropeo", props2.getProperty("ca?uto")); |
|
131 |
TestCase.assertEquals("cto=amigo", props2.getProperty("confli")); |
|
132 |
TestCase.assertEquals(":cto mayor = peque?o conflicto", props2.getProperty("conflis")); |
|
133 |
|
|
134 |
discardInputStream(); |
|
135 |
discardOutputStream(); |
|
136 |
|
|
137 |
// write file |
|
138 |
props1 = new OrderedProperties(); |
|
139 |
props1.setProperty("Prueba", "hola"); |
|
140 |
props1.setProperty("prueba2", "holas"); |
|
141 |
props1.setProperty("ca?uto", "\u20acuropeo"); |
|
142 |
props1.setProperty("confli=cto", "amigo"); |
|
143 |
props1.setProperty(" conflis = :cto mayor ", " peque?o conflicto"); |
|
144 |
props1.setProperty("abrir", "cerrar"); |
|
145 |
props1.setProperty("puerta", "hembrilla"); |
|
146 |
props1.setProperty("12libros", "quijote"); |
|
147 |
initOutputStream(); |
|
148 |
try { |
|
149 |
props1.store(os, "header", "UTF8"); |
|
150 |
} catch (IOException e) { |
|
151 |
TestCase.fail(e.getLocalizedMessage()); |
|
152 |
} |
|
153 |
|
|
154 |
// read file |
|
155 |
props2 = new OrderedProperties(); |
|
156 |
initInputStream(); |
|
157 |
try { |
|
158 |
props2.load(is, "UTF8"); |
|
159 |
} catch (IOException e) { |
|
160 |
TestCase.fail(e.getLocalizedMessage()); |
|
161 |
} |
|
162 |
// estos deber?an salir igual |
|
163 |
TestCase.assertEquals("hola", props2.getProperty("Prueba")); |
|
164 |
TestCase.assertEquals("holas", props2.getProperty("prueba2")); |
|
165 |
TestCase.assertEquals("cerrar", props2.getProperty("abrir")); |
|
166 |
TestCase.assertEquals("hembrilla", props2.getProperty("puerta")); |
|
167 |
TestCase.assertEquals("quijote", props2.getProperty("12libros")); |
|
168 |
// con estos en cambio no obtenemos los mismos valores que escribimos anteriormente. Es normal, porque incluimos |
|
169 |
// caracteres especiales como ":" y "=". Para manejarlos correctamente necesitamos usas los m?todos load/store |
|
170 |
// sin encoding, los cuales s? escapan los caracteres especiales |
|
171 |
TestCase.assertEquals("\u20acuropeo", props2.getProperty("ca?uto")); |
|
172 |
TestCase.assertEquals("cto=amigo", props2.getProperty("confli")); |
|
173 |
TestCase.assertEquals(":cto mayor = peque?o conflicto", props2.getProperty("conflis")); |
|
174 |
|
|
175 |
discardInputStream(); |
|
176 |
discardOutputStream(); |
|
177 |
} |
|
178 |
|
|
179 |
} |
|
0 | 180 |
tags/v_1_12_0_Build_1402/libInternationalization/src-utils-test/org/gvsig/i18n/utils/TestUtils.java | ||
---|---|---|
1 |
package org.gvsig.i18n.utils; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
|
|
8 |
/** |
|
9 |
* @author cesar |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class TestUtils extends TestCase { |
|
13 |
|
|
14 |
public ConfigOptions loadConfig() { |
|
15 |
ConfigOptions config = new ConfigOptions(); |
|
16 |
config.setConfigFile("src-test"+File.separator+"org"+File.separator+"gvsig"+File.separator+"i18n"+File.separator+"utils"+File.separator+"config.xml"); |
|
17 |
config.load(); |
|
18 |
return config; |
|
19 |
} |
|
20 |
|
|
21 |
public void testConfigOptions() { |
|
22 |
ConfigOptions config = loadConfig(); |
|
23 |
|
|
24 |
String databaseDir=null, basedir=null; |
|
25 |
try { |
|
26 |
databaseDir = new File("test-data/database").getCanonicalPath(); |
|
27 |
basedir = new File("test-data").getCanonicalPath(); |
|
28 |
} catch (IOException e) { |
|
29 |
// TODO Auto-generated catch block |
|
30 |
e.printStackTrace(); |
|
31 |
} |
|
32 |
|
|
33 |
// the values of the projects. They are pairs (dir, basename). |
|
34 |
String projectValues[]={"src/appgvSIG", "otro", "sources", "src/_fwAndami", "text", "sources"}; |
|
35 |
for (int i=0; i<projectValues.length; i=i+3) { |
|
36 |
try { |
|
37 |
// set the canonical path |
|
38 |
projectValues[i]= new File(basedir+File.separator+projectValues[i]).getCanonicalPath(); |
|
39 |
} catch (IOException e) { |
|
40 |
// TODO Auto-generated catch block |
|
41 |
e.printStackTrace(); |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
TestCase.assertEquals(databaseDir, config.databaseDir); |
|
46 |
TestCase.assertEquals(basedir, config.defaultBaseDir); |
|
47 |
TestCase.assertEquals("text", config.defaultBaseName); |
|
48 |
|
|
49 |
String languages = config.languages[0]; |
|
50 |
for (int i=1; i<config.languages.length; i++) { |
|
51 |
languages=languages+";"+config.languages[i]; |
|
52 |
} |
|
53 |
TestCase.assertEquals("ca;cs;de;en;es;eu;fr;gl;it;pt", languages); |
|
54 |
|
|
55 |
for (int i=0; i<config.projects.size(); i=i+3) { |
|
56 |
Project project = (Project) config.projects.get(i); |
|
57 |
TestCase.assertEquals(projectValues[i], project.dir); |
|
58 |
TestCase.assertEquals(projectValues[i+1], project.basename); |
|
59 |
TestCase.assertEquals(projectValues[i+2], project.sourceKeys); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
public void testTranslationDatabase() { |
|
64 |
ConfigOptions config = loadConfig(); |
|
65 |
TranslationDatabase database = new TranslationDatabase(config); |
|
66 |
database.load(); |
|
67 |
TestCase.assertEquals("A?adir Capa" , database.getTranslation("es", "Anadir_Capa")); |
|
68 |
TestCase.assertEquals("Add Layer" , database.getTranslation("en", "Anadir_Capa")); |
|
69 |
TestCase.assertEquals("Afegir Capa" , database.getTranslation("ca", "Anadir_Capa")); |
|
70 |
TestCase.assertEquals("Layer hinzuf?gen" , database.getTranslation("de", "Anadir_Capa")); |
|
71 |
TestCase.assertEquals("Ayuda" , database.getTranslation("es", "Ayuda")); |
|
72 |
TestCase.assertEquals(null , database.getTranslation("es", "test_case.clave_que_no_existe")); |
|
73 |
|
|
74 |
// add a translation |
|
75 |
database.setTranslation("es", "test_case.clave_que_no_existe", "Clave que no existe"); |
|
76 |
// is it present now? |
|
77 |
TestCase.assertEquals("Clave que no existe" , database.getTranslation("es", "test_case.clave_que_no_existe")); |
|
78 |
|
|
79 |
// remove the translation |
|
80 |
database.removeTranslation("es", "test_case.clave_que_no_existe"); |
|
81 |
// was really removed? |
|
82 |
TestCase.assertEquals(null , database.getTranslation("es", "test_case.clave_que_no_existe")); |
|
83 |
|
|
84 |
// add the translation again |
|
85 |
database.setTranslation("es", "test_case.clave_que_no_existe", "Clave que no existe"); |
|
86 |
// save to disk |
|
87 |
database.save(); |
|
88 |
// load from disk |
|
89 |
database.load(); |
|
90 |
// is the translation still there? |
|
91 |
TestCase.assertEquals("Clave que no existe" , database.getTranslation("es", "test_case.clave_que_no_existe")); |
|
92 |
|
|
93 |
// remove the translation again and save to disk |
|
94 |
database.removeTranslation("es", "test_case.clave_que_no_existe"); |
|
95 |
TestCase.assertEquals(null , database.getTranslation("es", "test_case.clave_que_no_existe")); |
|
96 |
TestCase.assertEquals("", database.getTranslation("es", "prueba")); |
|
97 |
database.save(); |
|
98 |
} |
|
99 |
|
|
100 |
public void testKeys() { |
|
101 |
ConfigOptions config = loadConfig(); |
|
102 |
Keys keys = new Keys(config); |
|
103 |
keys.load(); |
|
104 |
} |
|
105 |
|
|
106 |
} |
|
0 | 107 |
tags/v_1_12_0_Build_1402/libInternationalization/src-utils-test/org/gvsig/i18n/utils/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<config> |
|
3 |
<!-- Aquí especificamos algunas variables de configuración --> |
|
4 |
<!-- En este fichero se muestran todas las opciones posibles, en sus valores por defecto --> |
|
5 |
|
|
6 |
<!-- Nombre base por defecto de los ficheros con las traducciones. En nuestro caso suele ser "text", |
|
7 |
de forma que los ficheros toman nombres como "text.properties", "text_en.properties". Nótese |
|
8 |
que sólo es el nombre por defecto. Cada proyecto puede especificar un baseName distinto --> |
|
9 |
<variable name="basename" value="text" /> |
|
10 |
|
|
11 |
<!-- Directorio base. Las rutas relativas especificadas en otras variables (databaseDir, directorios |
|
12 |
de proyecto) tomarán este directorio como directorio base. Por defecto es el directorio |
|
13 |
desde el que se llama a la aplicación --> |
|
14 |
<variable name="basedir" value="test-data" /> |
|
15 |
|
|
16 |
<!-- Lista de idiomas que se tendrán en cuenta --> |
|
17 |
<variable name="languages" value="ca;cs;de;en;es;eu;fr;gl;it;pt" /> |
|
18 |
|
|
19 |
<!-- El directorio que contendrá la base de datos de traducciones por idioma. Por defecto es el |
|
20 |
directorio "database", relativo al directorio especificado en la variable "basedir". --> |
|
21 |
<variable name="databaseDir" value="database" /> |
|
22 |
|
|
23 |
<!-- El directorio por defecto que contendrá los property files que almacenan las claves de cada |
|
24 |
proyecto". Esto se usa en los proyectos que no especifican un atributo "propertyDir". Si el |
|
25 |
directorio no es absoluto, entonces es relativo al directorio de cada proyecto. --> |
|
26 |
<variable name="defaultPropertyDir" value="config" /> |
|
27 |
|
|
28 |
<variable name="sourceKeys" value="sources" /> |
|
29 |
</config> |
|
30 |
<projects> |
|
31 |
<!-- Los proyectos que se van a leer. Es necesario especificar un directorio (relativo o absoluto), |
|
32 |
y opcionalmente se puede incluir un atributo "basename" para especificar un nombre base |
|
33 |
distinto del nombre base por defecto --> |
|
34 |
<!-- The projects which are going to be read. An absolute or relative directory name must be specified, |
|
35 |
in which the property files are located. An optional "basename" attribute is also accepted, |
|
36 |
to override the default basename --> |
|
37 |
<project dir="src/appgvSIG" basename="otro" sourceKeys="sources" propertyDir="config" /> |
|
38 |
<project dir="src/_fwAndami" /> |
|
39 |
</projects> |
|
0 | 40 |
tags/v_1_12_0_Build_1402/libInternationalization/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libInternationalization</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/TestMessages.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.gvsig.i18n; |
|
5 |
|
|
6 |
import java.io.File; |
|
7 |
import java.net.MalformedURLException; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Locale; |
|
10 |
|
|
11 |
import junit.framework.TestCase; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author cesar |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class TestMessages extends TestCase { |
|
18 |
|
|
19 |
/* |
|
20 |
* @see TestCase#setUp() |
|
21 |
*/ |
|
22 |
protected void setUp() throws Exception { |
|
23 |
super.setUp(); |
|
24 |
} |
|
25 |
|
|
26 |
/* |
|
27 |
* @see TestCase#tearDown() |
|
28 |
*/ |
|
29 |
protected void tearDown() throws Exception { |
|
30 |
super.tearDown(); |
|
31 |
} |
|
32 |
|
|
33 |
public void testSetPreferredLocales() { |
|
34 |
setPreferredLocales(); |
|
35 |
removeLocales(); |
|
36 |
} |
|
37 |
|
|
38 |
private void setPreferredLocales() { |
|
39 |
ArrayList preferred = new ArrayList(); |
|
40 |
preferred.add(new Locale("en")); |
|
41 |
preferred.add(new Locale("es")); |
|
42 |
Messages.setPreferredLocales(preferred); |
|
43 |
ArrayList resultPref = Messages.getPreferredLocales(); |
|
44 |
|
|
45 |
TestCase.assertEquals(resultPref.size(), 2); |
|
46 |
|
|
47 |
Locale lang1 = (Locale) resultPref.get(0); |
|
48 |
TestCase.assertEquals(lang1.getLanguage(), "en"); |
|
49 |
Locale lang2 = (Locale) resultPref.get(1); |
|
50 |
TestCase.assertEquals(lang2.getLanguage(), "es"); |
|
51 |
} |
|
52 |
|
|
53 |
private void removeLocales() { |
|
54 |
Locale lang1 = new Locale("en"); |
|
55 |
Locale lang2 = new Locale("es"); |
|
56 |
ArrayList resultPref = Messages.getPreferredLocales(); |
|
57 |
Messages.removeLocale(lang1); |
|
58 |
TestCase.assertEquals(resultPref.size(), 1); |
|
59 |
Messages.removeLocale(lang2); |
|
60 |
TestCase.assertEquals(resultPref.size(), 0); |
|
61 |
} |
|
62 |
|
|
63 |
public void testAddResourceFamily() { |
|
64 |
setPreferredLocales(); |
|
65 |
//this.getClass().getClassLoader().getResource("text_en.properties"); |
|
66 |
|
|
67 |
try { |
|
68 |
Messages.addResourceFamily("text", new File("bin-test/org/gvsig/i18n/dataset1/")); |
|
69 |
} catch (MalformedURLException e) { |
|
70 |
TestCase.fail("Fichero de recursos no encontrado"); |
|
71 |
} |
|
72 |
TestCase.assertEquals(5, Messages.size(new Locale("en"))); |
|
73 |
TestCase.assertEquals(4,Messages.size(new Locale("es"))); |
|
74 |
TestCase.assertEquals(0,Messages.size(new Locale("fr"))); |
|
75 |
|
|
76 |
TestCase.assertEquals("OK", Messages.getText("aceptar")); |
|
77 |
TestCase.assertEquals("Cancel", Messages.getText("cancelar")); |
|
78 |
TestCase.assertEquals("Cascade", Messages.getText("Cascada")); |
|
79 |
TestCase.assertEquals("Window", Messages.getText("ventana")); |
|
80 |
TestCase.assertEquals("Debe haber al menos una ventana abierta", Messages.getText("cascada_enable")); |
|
81 |
TestCase.assertEquals("Configurar", Messages.getText("Configurar")); |
|
82 |
TestCase.assertEquals(null, Messages.getText("Configurar", false)); |
|
83 |
|
|
84 |
// load another file now |
|
85 |
try { |
|
86 |
Messages.addResourceFamily("text", new File("bin-test/org/gvsig/i18n/dataset2/")); |
|
87 |
} catch (MalformedURLException e) { |
|
88 |
TestCase.fail("Fichero de recursos no encontrado"); |
|
89 |
} |
|
90 |
// check that the right amount of translations was loaded |
|
91 |
TestCase.assertEquals(7, Messages.size(new Locale("en"))); |
|
92 |
TestCase.assertEquals(6, Messages.size(new Locale("es"))); |
|
93 |
TestCase.assertEquals(0, Messages.size(new Locale("fr"))); |
|
94 |
|
|
95 |
// test that keys didn't get overwritten by the new files |
|
96 |
// (only new keys should have been added for each language) |
|
97 |
TestCase.assertEquals("OK", Messages.getText("aceptar")); |
|
98 |
TestCase.assertEquals("Cancel", Messages.getText("cancelar")); |
|
99 |
TestCase.assertEquals("Cascade", Messages.getText("Cascada")); |
|
100 |
// check the new keys |
|
101 |
TestCase.assertEquals("At least one window should be open", Messages.getText("cascada_enable")); |
|
102 |
TestCase.assertEquals("Insert first corner point", Messages.getText("insert_first_point_corner")); |
|
103 |
TestCase.assertEquals("Capa exportada", Messages.getText("capa_exportada")); |
|
104 |
TestCase.assertEquals("Circunscrito", Messages.getText("circumscribed")); |
|
105 |
|
|
106 |
Messages.removeResources(); |
|
107 |
TestCase.assertEquals(0, Messages.size(new Locale("en"))); |
|
108 |
TestCase.assertEquals(0, Messages.size(new Locale("es"))); |
|
109 |
TestCase.assertEquals(0, Messages.size(new Locale("fr"))); |
|
110 |
|
|
111 |
removeLocales(); |
|
112 |
} |
|
113 |
} |
|
0 | 114 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/dataset2/text_fr.properties | ||
---|---|---|
1 |
#text_fr.properties |
|
2 |
aceptar=Accepter |
|
3 |
Cascada=Cascade |
|
4 |
Configurar=Configurer |
|
0 | 5 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/dataset2/text.properties | ||
---|---|---|
1 |
#text.properties |
|
2 |
aceptar=baceptar |
|
3 |
cancelar=amancebar |
|
4 |
capa_exportada=Capa exportada |
|
5 |
circumscribed=Circunscrito |
|
0 | 6 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/dataset2/text_en.properties | ||
---|---|---|
1 |
#text_en.properties |
|
2 |
insert_first_point_corner=Insert first corner point |
|
3 |
cascada_enable=At least one window should be open |
|
4 |
cancelar=arancelar |
|
0 | 5 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.i18n; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestSuite; |
|
5 |
|
|
6 |
public class AllTests { |
|
7 |
|
|
8 |
public static Test suite() { |
|
9 |
TestSuite suite = new TestSuite("Test for org.gvsig.i18n"); |
|
10 |
//$JUnit-BEGIN$ |
|
11 |
suite.addTestSuite(TestMessages.class); |
|
12 |
//$JUnit-END$ |
|
13 |
return suite; |
|
14 |
} |
|
15 |
|
|
16 |
} |
|
0 | 17 |
tags/v_1_12_0_Build_1402/libInternationalization/src-test/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/v_1_12_0_Build_1402/libInternationalization/src-test/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/v_1_12_0_Build_1402/libInternationalization/src-test/org/gvsig/i18n/dataset1/text_fr.properties | ||
---|---|---|
1 |
#text_fr.properties |
|
2 |
aceptar=Accepter |
|
3 |
Cascada=Cascade |
|
4 |
Configurar=Configurer |
|
0 | 5 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_en_US.properties | ||
---|---|---|
1 |
#Translations for language [en_US] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Ok |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_eu.properties | ||
---|---|---|
1 |
#Translations for language [eu] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
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/v_1_12_0_Build_1402/libInternationalization/config/text_nl.properties | ||
---|---|---|
1 |
#Translations for language [nl] |
|
2 |
#Tue Aug 11 10:49:16 CEST 2009 |
|
3 |
aceptar= |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_pl.properties | ||
---|---|---|
1 |
#Translations for language [pl] |
|
2 |
#Thu Oct 29 12:16:22 CET 2009 |
|
3 |
aceptar=Akceptuj |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_it.properties | ||
---|---|---|
1 |
#Translations for language [it] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Accetta |
|
4 |
Las_traducciones_no_pudieron_ser_cargadas=Non \u00e8 stato possibile caricare le traduzioni |
|
5 |
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase= |
|
6 |
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=Non esiste la lista dei linguaggi preferiti. Probabilmente la classe Messages non \u00e8 stata inizializzata |
|
7 |
No_se_encontro_la_traduccion_para=Non si \u00e9 incontrata la traduzione per |
|
0 | 8 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text.properties | ||
---|---|---|
1 |
#Translations for language [es] |
|
2 |
#Mon Sep 21 10:02:17 CEST 2009 |
|
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/v_1_12_0_Build_1402/libInternationalization/config/text_ro.properties | ||
---|---|---|
1 |
#Translations for language [ro] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Accept |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_zh.properties | ||
---|---|---|
1 |
#Translations for language [zh] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=\u786e\u5b9a |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_ca.properties | ||
---|---|---|
1 |
#Translations for language [ca] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
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/v_1_12_0_Build_1402/libInternationalization/config/text_pt.properties | ||
---|---|---|
1 |
#Translations for language [pt] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Aceitar |
|
4 |
Las_traducciones_no_pudieron_ser_cargadas=As tradu\u00e7\u00f5es n\u00e3o poderam ser carregadas |
|
5 |
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=N\u00e3o existe uma lista de idiomas preferidos. Talvez a classe n\u00e3o tenha sido iniciada. |
|
6 |
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=N\u00e3o existe uma lista de idiomas preferidos. Talvez a classe n\u00e3o tenha sido iniciada. |
|
7 |
No_se_encontro_la_traduccion_para=N\u00e3o se encontrou a tradu\u00e7\u00e3o de |
|
0 | 8 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_sr.properties | ||
---|---|---|
1 |
#Translations for language [sr] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Prihvati |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_tr.properties | ||
---|---|---|
1 |
#Translations for language [tr] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Kabul et |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_ru.properties | ||
---|---|---|
1 |
#Translations for language [ru] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=\u041e\u041a |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_de.properties | ||
---|---|---|
1 |
#Translations for language [de] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=OK |
|
4 |
Las_traducciones_no_pudieron_ser_cargadas=\u00dcbersetzung konnte nicht geladen werden |
|
5 |
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=Keine bevorzugte Spracheinstellung. M\u00f6glicherweise wurde die Klasse nicht korrekt eingebunden |
|
6 |
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=Keine bevorzugte Spracheinstellung. M\u00f6glicherweise wurde die Klasse nicht korrekt eingebunden |
|
7 |
No_se_encontro_la_traduccion_para=Konnte \u00dcbersetzung nicht finden f\u00fcr\: |
|
0 | 8 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_sw.properties | ||
---|---|---|
1 |
#Translations for language [sw] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Idhinisha |
|
0 | 4 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_el.properties | ||
---|---|---|
1 |
#Translations for language [el] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=\u0391\u03c0\u03bf\u03b4\u03bf\u03c7\u03ae |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_gl.properties | ||
---|---|---|
1 |
#Translations for language [gl] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
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/v_1_12_0_Build_1402/libInternationalization/config/text_en.properties | ||
---|---|---|
1 |
#Translations for language [en] |
|
2 |
#Mon Sep 21 10:02:17 CEST 2009 |
|
3 |
aceptar=Accept |
|
4 |
Las_traducciones_no_pudieron_ser_cargadas=Translations haven't could be loaded |
|
5 |
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=There is no list of favorite languages probably you forgot initialice the class |
|
6 |
No_hay_lista_de_idiomas_preferidos_quiza_olvido_inicializar_clase=There is not preferred languages list. Maybe the Messages class was not initiated |
|
7 |
No_se_encontro_la_traduccion_para=Cannot find translation for |
|
0 | 8 |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_cs.properties | ||
---|---|---|
1 |
#Translations for language [cs] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=Budi\u017e |
|
4 |
Las_traducciones_no_pudieron_ser_cargadas= |
|
5 |
No.hay.lista.de.idiomas.preferidos.quiza.olvido.inicializar.clase=Neexistuje seznam obl\u00edben\u00fdch jazyk\u016f, mo\u017en\u00e1 jste zapom\u011bl inicializovat t\u0159\u00eddu |
|
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/v_1_12_0_Build_1402/libInternationalization/config/text_pt_BR.properties | ||
---|---|---|
1 |
#Translations for language [pt_BR] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
3 |
aceptar=aceitar |
tags/v_1_12_0_Build_1402/libInternationalization/config/text_fr.properties | ||
---|---|---|
1 |
#Translations for language [fr] |
|
2 |
#Mon Sep 21 10:02:18 CEST 2009 |
|
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=Aucune liste de pr\u00e9f\u00e9rences du langage initialis\u00e9e. |
|
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/v_1_12_0_Build_1402/libInternationalization/src-utils/org/gvsig/i18n/utils/AddNewTranslations.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.gvsig.i18n.utils; |
|
5 |
|
|
6 |
import java.io.BufferedReader; |
|
7 |
import java.io.File; |
|
8 |
import java.io.FileInputStream; |
|
9 |
import java.io.FileNotFoundException; |
|
10 |
import java.io.IOException; |
|
11 |
import java.io.InputStreamReader; |
|
12 |
import java.io.UnsupportedEncodingException; |
|
13 |
import java.util.Enumeration; |
|
14 |
import java.util.Properties; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author cesar |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class AddNewTranslations { |
|
21 |
// The filename which stores the configuration (may be overriden by the command line parameter) |
|
22 |
private String configFileName = "config.xml"; |
|
23 |
|
|
24 |
// Object to load and store the config options |
|
25 |
private ConfigOptions config; |
|
26 |
|
|
27 |
private TranslationDatabase database; |
|
28 |
|
|
29 |
/** |
|
30 |
* @param args |
|
31 |
*/ |
|
32 |
public static void main(String[] args) { |
|
33 |
AddNewTranslations process = new AddNewTranslations(); |
|
34 |
|
|
35 |
// load command line parameters |
|
36 |
if (!process.readParameters(args)) { |
|
37 |
usage(); |
|
38 |
System.exit(-1); |
|
39 |
} |
|
40 |
|
|
41 |
// transfer control to the program's main loop |
|
42 |
process.start(); |
|
43 |
} |
|
44 |
|
|
45 |
private void start() { |
|
46 |
// load config options from the config file |
|
47 |
if (!loadConfig()) { |
|
48 |
System.out.println("Error leyendo el fichero de configuraci?n."); |
|
49 |
usage(); |
|
50 |
System.exit(-1); |
|
51 |
} |
|
52 |
|
|
53 |
loadDataBase(); |
|
54 |
|
|
55 |
readNewTranslations(); |
|
56 |
|
|
57 |
database.save(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Reads the command line parameters */ |
|
62 |
private boolean readParameters(String[] args) { |
|
63 |
String configPair[]; |
|
64 |
|
|
65 |
for (int i=0; i<args.length; i++) { |
|
66 |
configPair = args[i].split("=",2); |
|
67 |
if ( (configPair[0].equals("-c") || configPair[0].equals("--config")) |
|
68 |
&& configPair.length==2) { |
|
69 |
configFileName = configPair[1]; |
|
70 |
} |
|
71 |
else { |
|
72 |
return false; |
|
73 |
} |
|
74 |
} |
|
75 |
return true; |
|
76 |
} |
|
77 |
|
|
78 |
private boolean loadConfig() { |
|
79 |
config = new ConfigOptions(configFileName); |
|
80 |
config.load(); |
|
81 |
return true; |
|
82 |
} |
|
83 |
|
|
84 |
private static void usage() { |
|
85 |
System.out.println("Uso: AddNewTranslations [OPCION]"); |
|
86 |
System.out.println("\t-c\t--config=configFile"); |
|
87 |
} |
|
88 |
|
|
89 |
private void loadDataBase() { |
|
90 |
database = new TranslationDatabase(config); |
|
91 |
database.load(); |
|
92 |
} |
|
93 |
|
|
94 |
private void readNewTranslations() { |
|
95 |
String lang, key, value, oldValue; |
|
96 |
|
|
97 |
for (int i=0; i<config.languages.length; i++) { |
|
98 |
lang = config.languages[i]; |
|
99 |
try { |
|
100 |
FileInputStream fisProp = new FileInputStream(config.inputDir+File.separator+config.defaultBaseName+"_"+lang+".properties"); |
|
101 |
Properties prop = new Properties(); |
|
102 |
try { |
|
103 |
prop.load(fisProp); |
|
104 |
Enumeration keysEnum = prop.keys(); |
|
105 |
while (keysEnum.hasMoreElements()){ |
|
106 |
key = (String) keysEnum.nextElement(); |
|
107 |
value = prop.getProperty(key); |
|
108 |
if (value!=null && !value.equals("")) { |
|
109 |
if (!database.containsKey(lang, key)) { |
|
110 |
System.out.println("["+lang+"] Traducci?n a?adida -- "+key+"="+value); |
|
111 |
database.setTranslation(lang, key, value); |
|
112 |
} |
|
113 |
else { |
|
114 |
oldValue = database.setTranslation(lang, key, value); |
|
115 |
if (!oldValue.equals(value)) { |
|
116 |
System.out.println("["+lang+"] Traducci?n actualizada -- "+key+"="+value); |
|
117 |
System.out.println("Valor anterior: "+database.getTranslation(lang, key)); |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
} catch (IOException e) { |
|
123 |
System.err.println("Error leyendo traducciones para idioma ["+lang+"]. "+e.getLocalizedMessage()); |
|
124 |
} |
|
125 |
|
|
126 |
} catch (FileNotFoundException e) { |
|
127 |
try { |
|
128 |
FileInputStream fis = new FileInputStream(config.inputDir+File.separator+config.defaultBaseName+"_"+lang+".properties-"+config.outputEncoding); |
|
129 |
|
|
130 |
BufferedReader currentFile=null; |
|
131 |
try { |
|
132 |
currentFile = new BufferedReader(new InputStreamReader(fis, config.outputEncoding)); |
|
133 |
} catch (UnsupportedEncodingException e1) { |
|
134 |
// TODO Auto-generated catch block |
|
135 |
e1.printStackTrace(); |
|
136 |
} |
|
137 |
|
|
138 |
String line = null; |
|
139 |
try { |
|
140 |
while((line = currentFile.readLine()) != null) { |
|
141 |
String[] parts = line.split("="); |
|
142 |
if (parts.length == 2) { |
|
143 |
key = parts[0]; |
|
144 |
value = parts[1]; |
|
145 |
if (value!=null && !value.equals("")) { |
|
146 |
if (!database.containsKey(lang, key)) { |
|
147 |
System.out.println("["+lang+"] Traducci?n a?adida -- "+key+"="+value); |
|
148 |
database.setTranslation(lang, key, value); |
|
149 |
} |
|
150 |
else { |
|
151 |
oldValue = database.setTranslation(lang, key, value); |
|
152 |
if (!oldValue.equals(value)) { |
|
153 |
System.out.println("["+lang+"] Traducci?n actualizada -- "+key+"="+value); |
|
154 |
System.out.println("Valor anterior: "+database.getTranslation(lang, key)); |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
else { |
|
160 |
System.err.println("Error leyendo traducciones para idioma ["+lang+"]."); |
|
161 |
System.err.println("L?nea: "+line); |
|
162 |
} |
|
163 |
} |
|
164 |
currentFile.close(); |
|
165 |
} catch (IOException ex) { |
|
166 |
System.err.println("Error leyendo traducciones para idioma ["+lang+"]. "+ex.getLocalizedMessage()); |
|
167 |
} |
|
168 |
|
|
169 |
} catch (FileNotFoundException e1) { |
|
170 |
System.out.println("Aviso -- no se encontraron nuevas traducciones para el idioma ["+lang+"]."); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
} |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
} |
|
0 | 179 |
tags/v_1_12_0_Build_1402/libInternationalization/src-utils/org/gvsig/i18n/utils/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<config> |
|
3 |
<!-- Aquí especificamos algunas variables de configuración --> |
|
4 |
<!-- En este fichero se muestran todas las opciones posibles, en sus valores por defecto --> |
|
5 |
|
|
6 |
<!-- Nombre base por defecto de los ficheros con las traducciones. En nuestro caso suele ser "text", |
|
7 |
de forma que los ficheros toman nombres como "text.properties", "text_en.properties". Nótese |
|
8 |
que sólo es el nombre por defecto. Cada proyecto puede especificar un baseName distinto --> |
|
9 |
<variable name="basename" value="text" /> |
|
10 |
|
|
11 |
<!-- Directorio base. Las rutas relativas especificadas en otras variables (databaseDir, directorios |
|
12 |
de proyecto) tomarán este directorio como directorio base. Por defecto es el directorio |
|
13 |
desde el que se llama a la aplicación --> |
|
14 |
<variable name="basedir" value="../" /> |
|
15 |
<variable name="languages" value="es;en;en_US;ca;gl;eu;de;cs;fr;it;pl;pt;pt_BR;ro;zh;ru;el;pl;tr;sr;sw" /> |
|
16 |
<!--variable name="languages" value="cs;de;en;es;eu;fr;it;pt;pt_br;ro;sr;sw" / --> |
|
17 |
|
|
18 |
<!-- El directorio que contendrá la base de datos general de traducciones por idioma. Por defecto es el |
|
19 |
directorio "database", relativo al directorio especificado en la variable "basedir". --> |
|
20 |
<variable name="databaseDir" value="libInternationalization/utils-data/database" /> |
|
21 |
|
|
22 |
<!-- El directorio por defecto que contendrá los property files que almacenan las claves de cada |
|
23 |
proyecto". Esto se usa en los proyectos que no especifican un atributo "propertyDir". Si el |
|
24 |
directorio no es absoluto, entonces es relativo al directorio de cada proyecto. --> |
|
25 |
<variable name="defaultPropertyDir" value="config" /> |
|
26 |
|
|
27 |
<!-- El directorio en el que se escribirán las cadenas para enviar a traducir. --> |
|
28 |
<variable name="outputDir" value="libInternationalization/utils-data/output" /> |
|
29 |
|
|
30 |
<!-- El directorio del que se leerán las nuevas cadenas traducidas, que se van a integrar |
|
31 |
a la base de datos. --> |
|
32 |
<variable name="inputDir" value="libInternationalization/utils-data/input" /> |
|
33 |
|
|
34 |
<!-- Los subdirectorios que contienen fuentes, relativos a cada directorio de |
|
35 |
proyecto. Si se especifican varios subdirectorios, deben ir separado por |
|
36 |
punto y coma (;). --> |
|
37 |
<variable name="srcDirs" value="src;config" /> |
|
38 |
|
|
39 |
|
|
40 |
<!-- Esta variable especifica el origen de las claves. Los valores posibles son "sources" y "properties". |
|
41 |
Con esta variable se define el conjunto de valores válidos (esto es, el conjunto de claves que |
|
42 |
o bien deben estar traducidas o bien debemos enviar a traducir). El valor por defecto es "sources". |
|
43 |
|
|
44 |
- "properties" significa que el conjunto de claves válido se determinará tomando las claves |
|
45 |
presentes en el fichero .properties del idioma principal de cada proyecto. El idioma |
|
46 |
principal de un proyecto se define con el atributo "mainLang" de cada proyecto (si existe), |
|
47 |
o con la variable general "mainLang" en caso contrario. |
|
48 |
- "sources" significa que el conjunto de claves válido se determina buscando en el código fuente del |
|
49 |
programa. Se buscarán llamadas a las funciones getText y getString y se tomarán las claves de la |
|
50 |
llamada, también se buscarán las claves presentes en el config.xml de cada extensión. |
|
51 |
|
|
52 |
Cada proyecto puede especificar un sourceKeys distinto. |
|
53 |
--> |
|
54 |
<variable name="sourceKeys" value="sources" /> |
|
55 |
|
|
56 |
</config> |
|
57 |
<projects> |
|
58 |
<!-- Los proyectos que se van a leer. Es necesario especificar un directorio (relativo o absoluto), |
|
59 |
y opcionalmente se puede incluir un atributo "basename" para especificar un nombre base |
|
60 |
distinto del nombre base por defecto --> |
|
61 |
<!-- The projects which are going to be read. An absolute or relative directory name must be specified, |
|
62 |
in which the property files are located. An optional "basename" attribute is also accepted, |
|
63 |
to override the default basename --> |
|
64 |
<project dir="appgvSIG" basename="text" sourceKeys="sources" propertyDir="config"/> |
|
65 |
<project dir="_fwAndami" /> |
|
66 |
<project dir="extAddEventTheme" /> |
|
67 |
<project dir="extAnnotations" /> |
|
68 |
<project dir="extArcims"/> |
|
69 |
<project dir="extCAD" /> |
|
70 |
<project dir="extCatalogAndGazetteer" /> |
|
71 |
<project dir="extCenterViewToPoint" /> |
|
72 |
<project dir="extDataLocator" /> |
|
73 |
<project dir="extDeriverdGeometries" /> |
|
74 |
<project dir="extExpressionField" /> |
|
75 |
<project dir="extGeoProcessing" /> |
|
76 |
<project dir="extGeoprocessingExtensions" /> |
|
77 |
<project dir="extGeoreferencing" /> |
|
78 |
<project dir="extHelp" /> |
|
79 |
<project dir="extHyperlink" /> |
|
80 |
<project dir="extJCRS" /> |
|
81 |
<project dir="extJDBC" /> |
|
82 |
<project dir="extLayerLoadingOrder" /> |
|
83 |
<project dir="extOracleSpacial"/> |
|
84 |
<project dir="extProjectBackup"/> |
|
85 |
<project dir="extQuickInfo"/> |
|
86 |
<project dir="extQuickPrint"/> |
|
87 |
<project dir="extRasterTools-SE" /> |
|
88 |
<project dir="extSDE" /> |
|
89 |
<project dir="extScripting" /> |
|
90 |
<project dir="extSelectionTools" /> |
|
91 |
<project dir="extSymbology" /> |
|
92 |
<project dir="extTableExport"/> |
|
93 |
<project dir="extTableImport"/> |
|
94 |
<project dir="extTableSummarize"/> |
|
95 |
<project dir="extWCS" /> |
|
96 |
<project dir="extWFS2" /> |
|
97 |
<project dir="extWMS" /> |
|
98 |
<project dir="libArcIMS" /> |
|
99 |
<project dir="libCorePlugin" /> |
|
100 |
<project dir="libCq CMS for java" /> |
|
101 |
<project dir="libDriverManager" /> |
|
102 |
<project dir="libDwg" /> |
|
103 |
<project dir="libFMap" /> |
|
104 |
<project dir="libInternationalization" /> |
|
105 |
<project dir="libIverUtiles" /> |
|
106 |
<project dir="libJCRS" /> |
|
107 |
<project dir="libUIComponent" /> |
|
108 |
<project dir="libRemoteServices" /> |
|
109 |
|
|
110 |
|
|
111 |
</projects> |
|
0 | 112 |
tags/v_1_12_0_Build_1402/libInternationalization/src-utils/org/gvsig/i18n/utils/Project.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.gvsig.i18n.utils; |
|
5 |
|
|
6 |
import java.util.HashMap; |
|
7 |
|
|
8 |
/** |
|
9 |
* Convenience class to manage the attributes of the project tag from the config.xml |
|
10 |
* file. |
|
11 |
* |
|
12 |
* |
|
13 |
* @author cesar |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class Project { |
|
17 |
|
|
18 |
public String dir; |
|
19 |
public String basename; |
|
20 |
|
|
21 |
/** |
|
22 |
* The directory which stores the property files of the project. |
|
23 |
*/ |
|
24 |
public String propertyDir; |
|
25 |
|
|
26 |
/** |
|
27 |
* Source of the keys: whether they are loaded from the property files of |
|
28 |
* the project or they are searched inside the sources. |
|
29 |
* <ul><li>sourceKeys="sources": The keys are searched inside the Java source |
|
30 |
* files and the config.xml files from the extensions.</li> |
|
31 |
* <li>sourceKeys="properties": The keys are loaded from the property files |
|
32 |
* of each project.</li></ul> |
|
33 |
*/ |
|
34 |
public String sourceKeys; |
|
35 |
|
|
36 |
/** |
|
37 |
* Stores the associated dictionaries. Each value of the |
|
38 |
* HashMap is a Properties object, containing the translations for each |
Also available in: Unified diff