Module:LangToWiki: Difference between revisions

From Wikimedia Foundation Governance Wiki
Content deleted Content added
Pols12 (talk | contribs)
+wikidata(): same, but replacing "-" with "_"
Pols12 (talk | contribs)
oops
Line 10: Line 10:
]]
]]
function p.wikidata(frame)
function p.wikidata(frame)
local prefix = p.main( frame.args[1] )
local prefix = p.main( frame )
return string.gsub(prefix, '-', '_')
return string.gsub(prefix, '-', '_')
end
end

Revision as of 20:33, 16 October 2022

Documentation for this module may be created at Module:LangToWiki/doc

local p = {}

local Title = require('Module:Titlelib')

--[[
	Returns the Wikidata database identifier for the interwiki related to the
	language code given as first argument.
	
	@see T253387
]]
function p.wikidata(frame)
	local prefix = p.main( frame )
	return string.gsub(prefix, '-', '_')
end

--[[
	Returns the interwiki prefix matching with the requested language code as
	first argument, or false if no interwiki match with that language.

	Args:
		1: language code
]]
function p.main(frame)
	local prefix = Title.langToWiki(frame.args[1])
	if prefix then
		return prefix
	else
		return frame.args[1]
	end
end

return p