Ignore:
Timestamp:
2017-05-03T10:21:59+02:00 (8 years ago)
Author:
bastik
Message:

applied #josm14421 - Language codes with dashes fail in Wikipedia tags (patch by nyurik)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java

    r33098 r33288  
    4646    private static final XPath X_PATH = XPath.getInstance();
    4747    private final String wikipediaLang;
     48    private final String siteId;
    4849
    4950    private WikipediaApp(final String wikipediaLang) {
     51
     52        // FIXME: the proper way to get any wiki's site id is through an API call:
     53        // https://zh-yue.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=general
     54        // use "wikiid" value. The value may be cached as it will never change
     55        String siteId = wikipediaLang.replace('-', '_');
     56        switch (siteId) {
     57            case "be_tarask":
     58                siteId = "be_x_old";
     59                break;
     60        }
     61
    5062        this.wikipediaLang = wikipediaLang;
     63        this.siteId = siteId + "wiki";
    5164    }
    5265
     
    263276                    "?action=wbgetentities" +
    264277                    "&props=sitelinks" +
    265                     "&sites=" + wikipediaLang + "wiki" +
    266                     "&sitefilter=" + wikipediaLang + "wiki" +
     278                    "&sites=" + siteId +
     279                    "&sitefilter=" + siteId +
    267280                    "&format=xml" +
    268281                    "&titles=" + articles.stream().map(Utils::encodeUrl).collect(Collectors.joining("|"));
Note: See TracChangeset for help on using the changeset viewer.