require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local warn = require('Module:Warning')
local realISO = require('Module:ISO_639_name')
--[=[
Get the language name, in English, for a given ISO 639 (-1, -2 or -3) code
Returns nil if the language is not in the lookup tables.
]=]
function p.language_name(code, failValue)
-- Only continue if we get passed a non-empty string for the code param
if code == nil or code == '' then
warn('No ISO code provided to [[Module:ISO 639]]')
return failValue
elseif type(code) ~= 'string' then
warn('ISO code \"' .. tostring(code) .. '\" is not a string')
return failValue
end
local name, success = realISO._iso_639_code_to_name({ code, ['hide-err'] = 'yes' })
if not success then
warn('ISO code \"' .. code .. '\" not recognized by [[Module:ISO 639]]')
return failValue
end
return name
end
return p