Module:LangToWiki: Difference between revisions

From Wikimedia Foundation Governance Wiki
Content deleted Content added
Pols12 (talk | contribs)
Created page with "local p = {} local Title = require('Module:Titlelib') --[[ 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) return Title.langToWiki(frame.args[1]) end return p"
 
m 5 revisions imported from meta:Module:LangToWiki: import
 
(4 intermediate revisions by one other user not shown)
Line 3: Line 3:
local Title = require('Module:Titlelib')
local Title = require('Module:Titlelib')


--[[
--[[ Returns the interwiki prefix matching with the requested language code as
Returns the Wikidata database identifier for the interwiki related to the
first argument, or false if no interwiki match with that language.
language code given as first argument.
@see T253387
]]
function p.wikidata(frame)
local prefix = p.main( frame )
local db_prefix = string.gsub(prefix, '-', '_')
return db_prefix
end

--[[
Returns the interwiki prefix matching with the requested language code as
first argument.
If no interwiki match with that language, the argument is returned as it is.


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



Latest revision as of 23:25, 22 January 2024

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 )
	local db_prefix = string.gsub(prefix, '-', '_')
	return db_prefix
end

--[[
	Returns the interwiki prefix matching with the requested language code as
	first argument.
	If no interwiki match with that language, the argument is returned as it is.

	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