Changeset 1512 in josm
- Timestamp:
- 2009-03-24T14:49:19+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r1496 r1512 424 424 static public String getLanguageCodeU() 425 425 { 426 String languageCode = Locale.getDefault().getLanguage(); 426 String languageCode = getLanguageCode(); 427 if(languageCode.equals("en")) 428 return ""; 427 429 return languageCode.substring(0,1).toUpperCase() + languageCode.substring(1) + ":"; 428 430 } 429 431 static public String getLanguageCode() 430 432 { 433 String full = Locale.getDefault().toString(); 434 if(full.equals("iw_IL")) 435 return "he"; 436 /* list of non-single codes supported by josm */ 437 else if(full.equals("en_GB")) 438 return full; 431 439 return Locale.getDefault().getLanguage(); 432 440 } -
trunk/src/org/openstreetmap/josm/actions/HelpAction.java
r1511 r1512 172 172 { 173 173 String title = url.substring(i); 174 if( !title.startsWith(languageCode) && !languageCode.equals("En:"))174 if(languageCode.length() != 0 && !title.startsWith(languageCode)) 175 175 title = languageCode + title; 176 176 langurl = url.substring(0, i) + title; … … 195 195 help.read(new StringReader(reader.read(this.url)), 196 196 help.getEditorKit().createDefaultDocument()); 197 if(help.getText(). indexOf(" Describe ") >= 0)197 if(help.getText().length() == 0) 198 198 { 199 199 if(lang) -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r1509 r1512 67 67 */ 68 68 protected byte[] updateData() { 69 String motd = ""; 70 String baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de"); 71 WikiReader wr = new WikiReader(baseurl); 72 String vers = ""; 73 String languageCode = Main.getLanguageCodeU(); 74 try { 75 motd = wr.read(baseurl + "/wiki/"+languageCode+"StartupPage"); 76 } catch (IOException ioe) { 77 try { 78 motd = wr.read(baseurl + "/wiki/StartupPage"); 79 } catch (IOException ioe2) { 80 motd = "<html>" + styles + "<body><h1>" + 81 "JOSM - " + tr("Java OpenStreetMap Editor") + 82 "</h1>\n<h2 align=\"center\">(" + 83 tr("Message of the day not available") + 84 ")</h2></html>"; 85 } 69 String motd = new WikiReader().readLang("StartupPage"); 70 if(motd.length() == 0) 71 { 72 motd = "<html>" + styles + "<body><h1>" + 73 "JOSM - " + tr("Java OpenStreetMap Editor") + 74 "</h1>\n<h2 align=\"center\">(" + 75 tr("Message of the day not available") + 76 ")</h2></html>"; 86 77 } 87 motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}", 88 AboutAction.getVersionString())); 78 else 79 { 80 motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}", 81 AboutAction.getVersionString())); 82 } 89 83 // Save this to prefs in case JOSM is updated so MOTD can be refreshed 90 84 Main.pref.putInteger("cache.motd.html.version", myVersion); -
trunk/src/org/openstreetmap/josm/tools/WikiReader.java
r1483 r1512 6 6 import java.io.InputStreamReader; 7 7 import java.net.URL; 8 9 import org.openstreetmap.josm.Main; 8 10 9 11 /** … … 20 22 } 21 23 24 public WikiReader() { 25 this.baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de"); 26 } 27 22 28 /** 23 29 * Read the page specified by the url and return the content. … … 32 38 BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8")); 33 39 if (url.startsWith(baseurl) && !url.endsWith("?format=txt")) 34 return readFromTrac(in , url);40 return readFromTrac(in); 35 41 return readNormal(in); 42 } 43 44 public String readLang(String text) { 45 String languageCode = Main.getLanguageCodeU(); 46 String url = baseurl + "/wiki/"+languageCode+text; 47 String res = ""; 48 try { 49 res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"))); 50 } catch (IOException ioe) {} 51 if(res.length() == 0 && languageCode.length() != 0) 52 { 53 url = baseurl + "/wiki/"+text; 54 try { 55 res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"))); 56 } catch (IOException ioe) {} 57 } 58 return res; 36 59 } 37 60 … … 45 68 } 46 69 47 private String readFromTrac(BufferedReader in , String url) throws IOException {70 private String readFromTrac(BufferedReader in) throws IOException { 48 71 boolean inside = false; 49 72 boolean transl = false; … … 66 89 transl = false; 67 90 } 91 if(b.indexOf(" Describe ") >= 0) 92 return ""; 68 93 return "<html>" + b + "</html>"; 69 94 }
Note:
See TracChangeset
for help on using the changeset viewer.