Ignore:
Timestamp:
2009-03-24T14:49:19+01:00 (16 years ago)
Author:
stoecker
Message:

fixed language handling for web access

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r1483 r1512  
    66import java.io.InputStreamReader;
    77import java.net.URL;
     8
     9import org.openstreetmap.josm.Main;
    810
    911/**
     
    2022    }
    2123
     24    public WikiReader() {
     25        this.baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de");
     26    }
     27
    2228    /**
    2329     * Read the page specified by the url and return the content.
     
    3238        BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"));
    3339        if (url.startsWith(baseurl) && !url.endsWith("?format=txt"))
    34             return readFromTrac(in, url);
     40            return readFromTrac(in);
    3541        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;
    3659    }
    3760
     
    4568    }
    4669
    47     private String readFromTrac(BufferedReader in, String url) throws IOException {
     70    private String readFromTrac(BufferedReader in) throws IOException {
    4871        boolean inside = false;
    4972        boolean transl = false;
     
    6689                transl = false;
    6790        }
     91        if(b.indexOf("      Describe ") >= 0)
     92            return "";
    6893        return "<html>" + b + "</html>";
    6994    }
Note: See TracChangeset for help on using the changeset viewer.