Module:User:Ruakh

Hello, you have come here looking for the meaning of the word Module:User:Ruakh. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Ruakh, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Ruakh in singular and plural. Everything you need to know about the word Module:User:Ruakh you have here. The definition of the word Module:User:Ruakh will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Ruakh, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This is a private module sandbox of Ruakh, for his own experimentation. Items in this module may be added and removed at Ruakh's discretion; do not rely on this module's stability.


local p = {}

p.json = require('Module:Json')

function p.echo(frame)
    return frame:getParent().args
end

function p.main(frame)
    if type(p]) == 'function' then
        return p](unpack(frame.args, 2))
    else
        return p]]
    end
end

-- Returns a JSON object that contains cases where {{t+|foo|...}} links to a site
-- other than foo.wiktionary.org. The key is the language code used in the translation
-- template (typically a "Wiktionary language code", though there are a few exceptions
-- defined in ]'s 'interwiki_langs' table); the value is
-- the corresponding site prefix ("Wikimedia language code").
function p.formatLangCodeToPrefixMapAsJson()
    all_language_data = mw.loadData("Module:languages/data/all")
    interwiki_langs = mw.loadData("Module:translations/data").interwiki_langs

	local merged = {}

    for lang_code, lang_info in pairs(all_language_data) do
		if type(lang_code) ~= 'string' then
			error('all_language_data contains non-string key: ' .. lang_code)
		end
		if type(lang_info) ~= 'table' then
			error('all_language_data contains non-table value: ' .. lang_info)
		end
        if lang_info.wikimedia_codes then
            merged = string.gsub(lang_info.wikimedia_codes, "%s*,.*", "")
        end
    end

    for key, value in pairs(interwiki_langs) do
		if type(key) ~= 'string' then
			error('interwiki_langs contains non-string key: ' .. key)
		end
		if type(value) ~= 'string' then
			error('interwiki_langs contains non-string value: ' .. value)
		end
        if merged == nil then
            merged = value
        else
            merged = merged
        end
	end
 
    return p.json.jsonObjectFromTable(merged, p.json.jsonStringFromString)
end

function p.faithfulJsonValueFromValue(val)
    if val == nil then
        return 'null'
    elseif val == true then
        return 'true'
    elseif val == false then
        return 'false'
    elseif type(val) == 'number' then
        return p.json.jsonNumberFromNumber(val)
    elseif type(val) == 'string' then
        return p.json.jsonStringFromString(val)
    elseif type(val) == 'table' then
        local ret = {}
        for key, value in pairs(val) do
            table.insert(ret, ', ')
            table.insert(ret, p.json.jsonStringFromString(p.faithfulJsonValueFromValue(key)))
            table.insert(ret, ': ')
            table.insert(ret, p.faithfulJsonValueFromValue(value))
        end
 
        if # ret == 0 then
            return '{}'
        end
 
        ret = '{ '
        table.insert(ret, ' }')
 
        return table.concat(ret)
    else
        error('Unsupported type: ' .. t)
    end
end

function p.formatEntryNameRulesAsJson()
    local result = {}

    -- normal languages:
    for langCode, langData in pairs(mw.loadData("Module:languages/data/all")) do
        result = langData.entry_name
    end

    -- etymology languages (which are also supported by {{t}}/{{t+}}):
    for langCode, langInfo in pairs(mw.loadData("Module:etymology languages/data")) do
        result = result]
    end

    return p.faithfulJsonValueFromValue(result)
end


function p.listArgPairs(frame)
    local ret = ''
    for key, value in pairs(frame.args) do
        ret = ret .. key .. '=>' .. value .. '<br />'
    end
    return ret
end

function p.strlen(s)
    return s:len()
end

function p.substring(s, i, j)
    return s:sub(i, j)
end

function p.bytewiseEscape(s)
    s = s:gsub('%p', '\\%0')
    s = s:gsub('\n', '\\n')
    s = s:gsub('', function (c)
            return string.format('\\x%02X', c:byte(1))
        end)
    s = s:gsub('^ ', '\\x20')
    s = s:gsub('  ', ' \\x20')
    s = s:gsub(' $', '\\x20')
    return s
end

return p