Module:I18n/or

From PsychonautWiki
Jump to: navigation, search

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

local p = { --indicate white =spaces before but not after "or" to be consistent with int:and
   ['ar'] = 'أو',
   ['bn'] = ' অথবা',
   ['ca'] = ' o',
   ['cs'] = ' nebo',
   ['da'] = ' eller',
   ['de'] = ' oder',
   ['el'] = ' ή',
   ['en'] = ' or',
   ['eo'] = ' aŭ',
   ['et'] = ' või',
   ['fa'] = 'یا ',
   ['fi'] = ' tai',
   ['fr'] = ' ou',
   ['gl'] = ' ou',
   ['he'] = ' או',
   ['hsb'] = ' abo',
   ['hu'] = ' vagy',
   ['it'] = ' o',
   ['ja'] = 'または',
   ['mk'] = ' или',
   ['ml'] = ' അഥവാ',
   ['nds'] = ' oder',
   ['nl'] = ' of',
   ['nn'] = ' eller',
   ['no'] = ' eller',
   ['os'] = ' ó',
   ['pl'] = ' lub',
   ['pt'] = ' ou',
   ['pt-br'] = ' ou',
   ['ru'] = ' или',
   ['sl'] = ' ali',
   ['sv'] = ' eller',
   ['tg'] = ' ё',
   ['th'] = ' หรือ',
   ['tr'] = ' ve',
   ['zh'] = ' 或',
}

setmetatable(p, { quickTests = function()
    for k, v in pairs(p) do
        if type(k) ~= 'string' or #k < 2 or #k > 16 or (k):find('^[a-z][%-0-9a-z]*[0-9a-z]$') ~= 1
        or type(v) ~= 'string' or #v < 1 or #v > 32 then return false, ": Invalid mapping for language code ['" .. tostring(k) .. "'] = '" .. tostring(v) .. "'" end
        if not mw.language.isSupportedLanguage(k) and not mw.language.isKnownLanguageTag(k) then return false, ": Unknown and unsupported language code '" .. tostring(k) .. "'" end
    end
    if p[mw.getContentLanguage():getCode()] == nil then return false, ": Missing mapping for content language ['" .. tostring(mw.getContentLanguage():getCode()) .. "']" end
    return true
end })
--[[ Type this to run quick tests in Lua console:
=getmetatable(p).quickTests() -- must return true
--]]

return p