Ticket #14421: fix-uncommon-wikilangs.patch

File fix-uncommon-wikilangs.patch, 1.7 KB (added by nyurik, 2 years ago)

patch to fix this issue

  • src/org/wikipedia/WikipediaApp.java

     
    4545    public static final Pattern WIKIDATA_PATTERN = Pattern.compile("Q\\d+");
    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
    5366    public static WikipediaApp forLanguage(final String wikipediaLang) {
     
    262275            final String url = "https://www.wikidata.org/w/api.php" +
    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("|"));
    269282            final Map<String, String> r = new TreeMap<>();