Module:R:DGE

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module implements {{R:DGE}}.


local u = require("Module:string/char")

local export = {}

function export.create(frame)
   local params = {
		[1] = {},
		["w"] = {},
	}
	local args, invalid_args, invalid_args_warning = require("Module:checkparams").process(frame:getParent(), params)
	local title = args['w'] or mw.title.getCurrentTitle().text
	local title_span = '<span class="Polyt" lang="grc">'..title..'</span>'
	-- replace U+03CC GREEK SMALL LETTER OMICRON WITH TONOS ([[ό]])
	-- with U+1F79 GREEK SMALL LETTER OMICRON WITH OXIA;
	-- the DGE website only accepts the latter.
	-- See [[Template talk:R:DGE#Characters with oxia]].
	local term = (args[1] or title):gsub(u(0x03CC), u(0x1F79))
	local termURLCode = mw.uri.encode(term, "PATH")
	local year = os.date("%Y")
	local link = ""
	if termURLCode == '' then
		link = "''[[w:Diccionario Griego–Español|Diccionario Griego–Español]]'' en línea (2006–"..year..")"
	else
		link = "[http://dge.cchs.csic.es/xdge/"..termURLCode..' '..title_span.."] in the ''[[w:Diccionario Griego–Español|Diccionario Griego–Español]]'' en línea (2006–"..year..")"
	end
	return link .. invalid_args_warning
end
 
return export