Changeset 31861 in osm


Ignore:
Timestamp:
2015-12-25T21:27:09+01:00 (9 years ago)
Author:
simon04
Message:

JOSM/wikipedia: Add fallback Wikidata label fetching - see #josm9775

Fetch Wikidata label in any language if neither program language nor English are present.

File:
1 edited

Legend:

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

    r31857 r31861  
    211211                    "&props=labels" +
    212212                    "&ids=" + wikidataId +
    213                     "&languages=" + preferredLanguage +
    214                     "&languagefallback=en" +
    215                     "&format=xml";
     213                    "&format=xml" +
     214                    (preferredLanguage != null ? "&languages=" + preferredLanguage + "&languagefallback=en" : "");
    216215            Main.info("Wikipedia: GET " + url);
    217216            try (final InputStream in = Utils.openURL(new URL(url))) {
    218217                final Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
    219218                final Node label = (Node) XPathFactory.newInstance().newXPath().compile("//label").evaluate(xml, XPathConstants.NODE);
    220                 if (label == null) {
     219                if (label == null && preferredLanguage != null) {
     220                    return getLabelForWikidata(wikidataId, null);
     221                } else if (label == null) {
    221222                    return null;
    222223                } else {
Note: See TracChangeset for help on using the changeset viewer.