/[schmitzm]/trunk/src/skrueger/i8n/TranslationTool.java
ViewVC logotype

Diff of /trunk/src/skrueger/i8n/TranslationTool.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 780 by alfonx, Wed Mar 31 13:39:02 2010 UTC revision 895 by alfonx, Fri Jun 4 16:29:24 2010 UTC
# Line 1  Line 1 
1  package skrueger.i8n;  package skrueger.i8n;
2  /*******************************************************************************  /*******************************************************************************
3   * Copyright (c) 2010 Stefan A. Krüger (soon changing to Stefan A. Tzeggai).   * Copyright (c) 2010 Stefan A. Tzeggai.
4   * All rights reserved. This program and the accompanying materials   * All rights reserved. This program and the accompanying materials
5   * are made available under the terms of the GNU Public License v2.0   * are made available under the terms of the GNU Public License v2.0
6   * which accompanies this distribution, and is available at   * which accompanies this distribution, and is available at
7   * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html   * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8   *   *
9   * Contributors:   * Contributors:
10   *     Stefan A. Krüger (soon changing to Stefan A. Tzeggai) - initial API and implementation   *     Stefan A. Tzeggai - initial API and implementation
11   ******************************************************************************/   ******************************************************************************/
12  import java.io.BufferedReader;  import java.io.BufferedReader;
13  import java.io.File;  import java.io.File;
14  import java.io.FileReader;  import java.io.FileReader;
15  import java.io.IOException;  import java.io.IOException;
16    import java.net.URISyntaxException;
17  import java.util.HashMap;  import java.util.HashMap;
18    import java.util.Locale;
19    
20    import schmitzm.lang.ResourceProvider;
21    
22    
23  /**  /**
24   * This tool helps to find missing frensh translations   * This tool helps to find missing french translations
25   *   *
26   */   */
27  public class TranslationTool {  public class TranslationTool {
28                    
29          static File GPenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/Geopublisher.properties");          static File GPenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/GeopublisherTranslation.properties");
30          static File GPfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/Geopublisher_fr.properties");          static File GPfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/GeopublisherTranslation_fr.properties");
31                    
32          static File ASenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation.properties");          static File ASenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation.properties");
33          static File ASfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation_fr.properties");          static File ASfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation_fr.properties");
34                    
35          static File AVenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation.properties");          static File AVenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation.properties");
36          static File AVfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation_fr.properties");          static File AVfrench = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation_fr.properties");
           
37                    
38          private static HashMap<String,String> frenshTranslations = new HashMap<String, String>();          private static HashMap<String,String> frenchTranslations = new HashMap<String, String>();
39    
40          /**          /**
41           * @param args           * @param args
42           * @throws IOException           * @throws IOException
43             * @throws URISyntaxException
44           */           */
45          public static void main(String[] args) throws IOException {          public static void main(String[] args) throws IOException, URISyntaxException {
46                    
47                    Locale dl = Locale.getDefault();
48                    
49                    for (ResourceProvider p : ResourceProvider.getRegisteredResourceProvider()){
50                            
51                            for (Locale l : p.getAvailableLocales(false)) {
52                                    File propertyFile = ResourceProvider.getPropertyFile(p, l, null);
53                            }
54                    }
55                                    
56                                    
57                  BufferedReader en_Reader;                  BufferedReader en_Reader;
# Line 48  public class TranslationTool { Line 61  public class TranslationTool {
61                                    
62                  if (mode == 1) {                  if (mode == 1) {
63                          en_Reader = new BufferedReader(new FileReader(GPenglish));                          en_Reader = new BufferedReader(new FileReader(GPenglish));
64                          fr_Reader = new BufferedReader(new FileReader(GPfrensh));                          fr_Reader = new BufferedReader(new FileReader(GPfrench));
65                  } else if (mode == 2) {                  } else if (mode == 2) {
66                          en_Reader = new BufferedReader(new FileReader(ASenglish));                          en_Reader = new BufferedReader(new FileReader(ASenglish));
67                          fr_Reader = new BufferedReader(new FileReader(ASfrensh));                          fr_Reader = new BufferedReader(new FileReader(ASfrench));
68                  } else {                  } else {
69                          en_Reader = new BufferedReader(new FileReader(AVenglish));                          en_Reader = new BufferedReader(new FileReader(AVenglish));
70                          fr_Reader = new BufferedReader(new FileReader(AVfrensh));                          fr_Reader = new BufferedReader(new FileReader(AVfrench));
71                  }                  }
72                                    
73    
74                  // Read all frensh translations keys into a HashMap                  // Read all french translations keys into a HashMap
75                  String  readLine = "start";                  String  readLine = "start";
76                  while (readLine != null) {                  while (readLine != null) {
77                          readLine = fr_Reader.readLine();                          readLine = fr_Reader.readLine();
# Line 67  public class TranslationTool { Line 80  public class TranslationTool {
80                                  if (indexOf == -1) continue;                                  if (indexOf == -1) continue;
81                                  String key =  readLine.substring(0,indexOf).trim();                                  String key =  readLine.substring(0,indexOf).trim();
82                                  String value =  readLine.substring(indexOf+1).trim();                                  String value =  readLine.substring(indexOf+1).trim();
83                                  frenshTranslations .put(key.trim(),value.trim());                                  frenchTranslations .put(key.trim(),value.trim());
84                          }                          }
85                  }                  }
86                                    
87                  System.out.println(frenshTranslations.size()+" frensh imported");                  System.out.println(frenchTranslations.size()+" french imported");
88    
89                  readLine = "start";                  readLine = "start";
90                  int missing =0;                  int missing =0;
# Line 83  public class TranslationTool { Line 96  public class TranslationTool {
96                                  if (indexOf == -1) continue;                                  if (indexOf == -1) continue;
97                                  String key =  readLine.substring(0,indexOf).trim();                                  String key =  readLine.substring(0,indexOf).trim();
98                                  String value =  readLine.substring(indexOf+1).trim();                                  String value =  readLine.substring(indexOf+1).trim();
99                                  if (!frenshTranslations.containsKey(key)) {                                  if (!frenchTranslations.containsKey(key)) {
100                                          System.out.println("#"+key+"="+value+"\n");                                          System.out.println("#"+key+"="+value+"\n");
101                                          missing++;                                          missing++;
102                                  }                                  }

Legend:
Removed from v.780  
changed lines
  Added in v.895

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26