Module:City: Difference between revisions
From Neodyland Wiki
More actions
←Created page with 'local p = {} local data = mw.loadData("Module:City/data") local wikidata = require "Module:Wikidata" function p._city(place, lang, link) local item if strin...' |
No edit summary |
||
| Line 5: | Line 5: | ||
function p._city(place, lang, link) | function p._city(place, lang, link) | ||
local item | local item | ||
if (not place) or (place == "") then | |||
return nil | |||
end | |||
if string.match(place, "Q%d+") then | if string.match(place, "Q%d+") then | ||
item = place | item = place | ||
else | else | ||
item = data[place] | item = data[mw.ustring.lower(place)] | ||
end | end | ||
if not item then | if not item then | ||
return place | return place | ||
end | end | ||
return wikidata. | return wikidata._getLabel(item, {lang = lang, link = link or "wikipedia"}) | ||
end | end | ||
function p.city( | function p.city(frame) | ||
local args = frame.args | local args = frame.args | ||
return p._city(args[1], args[lang], args[link]) | return p._city(args[1], args[lang], args[link]) | ||
end | end | ||
return p | |||
Revision as of 05:50, 30 July 2016
This documentation is transcluded from Module:City/doc.
local p = {}
local data = mw.loadData("Module:City/data")
local wikidata = require "Module:Wikidata"
function p._city(place, lang, link)
local item
if (not place) or (place == "") then
return nil
end
if string.match(place, "Q%d+") then
item = place
else
item = data[mw.ustring.lower(place)]
end
if not item then
return place
end
return wikidata._getLabel(item, {lang = lang, link = link or "wikipedia"})
end
function p.city(frame)
local args = frame.args
return p._city(args[1], args[lang], args[link])
end
return p