Module:Lang-utils

From Guild of Archivists
Revision as of 01:21, 17 July 2024 by BladeLakem (talk | contribs) (Created page with " export = {} require('Module:Lang-utils/data') m_p = require('Module:Parameters') function export.if_final_vowel(str,t_value,f_value,vowels) str = str or '' t_value = t_value or '' f_value = f_value or '' vowels = vowels or STD_VOWELS if string.find(vowels,string.sub(str,-1)) then return t_value else return f_value end end function export.ifv(frame) if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else orig...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Lang-utils/doc

export = {} 

require('Module:Lang-utils/data')

m_p = require('Module:Parameters')

function export.if_final_vowel(str,t_value,f_value,vowels) 
	str = str or ''
	t_value = t_value or ''
	f_value = f_value or ''
	vowels = vowels or STD_VOWELS
	
	if string.find(vowels,string.sub(str,-1)) then
		return t_value
	else
		return f_value
	end
	
end

function export.ifv(frame)
	if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame.args
    end
	
	return export.if_final_vowel(origArgs[1],origArgs[2],origArgs[3],origArgs[4])

		
end

function export.getLangName(code)
	code = code or ''
	
	output = LANGS[string.lower(code)] or "Unknown"
	
	return output
end

function export.langName(frame)
	if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame.args
    end
	
	return export.getLangName(origArgs[1])
		
end

return export