ମଡ୍ୟୁଲ:Language
Documentation for this module may be created at ମଡ୍ୟୁଲ:Language/doc
require('Module:No globals')local m_data = mw.loadData("Module:Language/data")local langData = m_data.languages or m_datalocal p = {}local function checkForString(variable)return variable ~= "" and variable ~= nilendlocal function makeLinkedName(languageCode)local data = langData[languageCode]local article = data["article"]local name = data["Wikipedia_name"] or data["name"]return "[[" .. article .. "|" .. name .. "]]: "endlocal function makeEntryName(word, languageCode)local data = langData[languageCode]local ugsub = mw.ustring.gsubword = tostring(word)if word == nil thenerror("The function makeEntryName requires a string argument")elseif word == "" thenreturn ""else-- Remove bold and italics, so that words that contain bolding or emphasis can be linked without piping.word = word:gsub("\'\'\'", "")word = word:gsub("\'\'", "")if data == nil thenreturn wordelselocal replacements = data and data["replacements"]if replacements == nil thenreturn wordelse-- Decompose so that the diacritics of characters such-- as á can be removed in one go.-- No need to compose at the end, because the MediaWiki software-- will handle that.if replacements.decompose thenword = mw.ustring.toNFD(word)for i, from in ipairs(replacements.from) doword = ugsub(word,from,replacements.to and replacements.to[i] or "")endelsefor regex, replacement in pairs(replacements) doword = ugsub(word, regex, replacement)endendreturn wordendendendendp.makeEntryName = makeEntryNamelocal function fixScriptCode(firstLetter, threeLetters)return string.upper(firstLetter) .. string.lower(threeLetters)endlocal function getCodes(codes, text)local languageCode, scriptCode, invalidCodelocal errorTextif codes == nil or codes == "" thenerrorText = 'no language or script code provided'-- Private-use subtag: x followed by one or more sequences of 1-8 lowercase-- letters separated by hyphens. This only allows for one sequence, as it is-- needed for proto-languages such as ine-x-proto (Proto-Indo-European).elseif codes:find("^%s*%a%a%a?%-x%-%a%a?%a?%a?%a?%a?%a?%a?$") thenlanguageCode, scriptCode =codes:match("^%s*(%a%a%a%-x%-%a%a?%a?%a?%a?%a?%a?%a?)%-?(.*)$")if not languageCode thenerrorText = '<code>'..codes..'</code> is not a valid language or script code.'elseif scriptCode ~= "" and not scriptCode:find("%a%a%a%a") thenerrorText = '<code>'..scriptCode..'</code> is not a valid script code.'elsescriptCode = scriptCode:gsub("(%a)(%a%a%a)",fixScriptCode,1)endelseif codes:find("^%s*%a%a%a?%s*$") or codes:find("^%s*%a%a%a?%-%a%a%a%a%s*$") then-- A three- or two-letter lowercase sequence at beginning of first parameterlanguageCode =codes:find("^%s*%a%a%a?") and (codes:match("^%s*(%l%l%l?)")or codes:match("^%s*(%a%a%a?)"):gsub("(%a%a%a?)", string.lower, 1))-- One uppercase and three lowercase letters at the end of the first parameterscriptCode =codes:find("%a%a%a%a%s*$") and (codes:match("(%u%l%l%l)%s*$")or gsub(codes:match("(%a%a%a%a)%s*$"),"(%a)(%a%a%a)",fixScriptCode,1))elseif codes:find("^%s*%a%a%a%-%a%a%a$") thenlanguageCode = codes:match("^%s*%l%l%l%-%l%l%l$") and codes:match("^%s*%l%l%l%-%l%l%l$")or codes:match("^%s*%a%a%a%-%a%a%a$"):gsub("(%a%a%a?)", string.lower, 1)elseif codes:find("^%s*%a%a%a?") thenlanguageCode, invalidCode = codes:match("^%s*(%a%a%a?)%-?(.*)")languageCode = string.lower(languageCode)errorText = '<code>'..invalidCode..'</code> is not a valid script code.'elseif codes:find("%-?%a%a%a%a%s*$") theninvalidCode, scriptCode = codes:match("(.*)%-?(%a%a%a%a)%s*$")scriptCode = gsub(scriptCode,"(%a)(%a%a%a)",fixScriptCode)errorText = '<code>'..invalidCode..'</code> is not a valid language code.'elseerrorText = '<code>'..codes..'</code> is not a valid language or script code.'endif not scriptCode or scriptCode == "" thenscriptCode = require("Module:Unicode data").is_Latin(text) and "Latn" or "unknown"endif errorText thenerrorText = ' <span style="font-size: smaller">[' .. errorText .. ']</span>'elseerrorText = ""endlanguageCode = m_data.redirects[languageCode] or languageCodereturn languageCode, scriptCode, errorTextendlocal function tag(text, languageCode, script, italics)local data = langData[languageCode]-- Use Wikipedia code if it has been given: for instance,-- Proto-Indo-European has the Wiktionary code "ine-pro" but the Wikipedia-- code "ine-x-proto".languageCode = data and data.Wikipedia_code or languageCodelocal italicize = script == "Latn" and italicsif not text then text = "[text?]" endlocal textDirectionMarkers = { "", "", "" }if data and data["direction"] == "rtl" thentextDirectionMarkers = { ' dir="rtl"', '‏', '‎' }endlocal out = { textDirectionMarkers[2] }if italicize thentable.insert(out, "<i lang=\"" .. languageCode .. "\" xml:lang=\"" .. languageCode .. "\"" .. textDirectionMarkers[1] .. ">" .. text .. "</i>")elsetable.insert(out, "<span lang=\"" .. languageCode .. "\" xml:lang=\"" .. languageCode .. "\"" .. textDirectionMarkers[1] .. ">" .. text .. "</span>")endtable.insert(out, textDirectionMarkers[3])return table.concat(out)endfunction p.lang(frame)local parent = frame:getParent()local args = parent.args[1] and parent.args or frame.argslocal codes = args[1]local text = args[2] or error("Provide text in the second parameter")local languageCode, scriptCode, errorText = getCodes(codes, text)local italics = args.italics or args.i or args.italicitalics = not (italics == "n" or italics == "-" or italics == "no")return tag(text, languageCode, scriptCode, italics) .. errorTextendlocal function linkToWiktionary(entry, linkText, languageCode)local data = langData[languageCode]local nameif languageCode thenif data and data.name thenname = data.nameelseif mw.language.fetchLanguageName(languageCode, 'en') ~= "" then-- On other languages' wikis, use mw.getContentLanguage():getCode(), or replace with that wiki's language code.name = mw.language.fetchLanguageName(languageCode, 'en')elseerror("No name for the language " .. ("%q"):format(languageCode or nil) .. " could be found")endif entry:sub(1, 1) == "*" thenif name ~= "" thenentry = "Reconstruction:" .. name .. "/" .. entry:sub(2)elseerror("Language name is empty")endelseif data and data.type == "reconstructed" thenmw.log("Reconstructed language without asterisk:", languageCode, name, entry)local frame = mw.getCurrentFrame()-- Track reconstructed entries with no asterisk by transcluding-- a nonexistent template. This technique is used in Wiktionary:-- see [[wikt:Module:debug]].-- [[Special:WhatLinksHere/tracking/wikt-lang/reconstructed with no asterisk]]pcall(frame.expandTemplate, frame,{ title = 'tracking/wikt-lang/reconstructed with no asterisk' })if name ~= "" thenentry = "Reconstruction:" .. name .. "/" .. entryelseerror("Language name is empty")endelseif data and data.type == "appendix" thenif name ~= "" thenentry = "Appendix:" .. name .. "/" .. entryelseerror("Language name is empty")endendif entry and linkText thenreturn "[[wikt:" .. entry .. "#" .. name .. "|" .. linkText .. "]]"elseerror("linkToWiktionary needs a Wiktionary entry or link text, or both")endelsereturn "[[wikt:" .. entry .. "|" .. linkText .. "]]"endendfunction p.wiktlang(frame)local parent = frame:getParent()local args = parent.args[1] and parent.args or frame.argslocal codes = args[1] or nillocal word1 = args[2] or nillocal word2 = args[3] or nilif not args[2] thenerror("Parameter 2 is required")endlocal languageCode, scriptCode, errorText = getCodes(codes, word1)local italics = args.italics or args.iitalics = not (italics == "n" or italics == "-")local entry, linkTextif checkForString(word2) and checkForString(word1) thenentry = makeEntryName(word1, languageCode)linkText = word2elseif checkForString(word1) thenentry = makeEntryName(word1, languageCode)linkText = word1endlocal outif languageCode and entry and linkText thenout = tag(linkToWiktionary(entry, linkText, languageCode), languageCode, scriptCode, italics)elseif entry and linkText thenout = linkToWiktionary(entry, linkText)elseout = '<span style="font-size: smaller;">[text?]</span>'endif out and errorText thenreturn out .. errorTextelsereturn errorText or error("The function wiktlang generated nothing")endendfunction p.wikt(frame)local parent = frame:getParent()local args = parent.args[1] and parent.args or frame.argslocal codes = args[1] or nillocal word1 = args[2] or nillocal word2 = args[3] or nilif not word1 thenerror("Provide a word in parameter 2.")endlocal languageCode, scriptCode, errorText = getCodes(codes, word1)local entry, linkTextif checkForString(word2) and checkForString(word1) thenentry = makeEntryName(word1, languageCode)linkText = word2elseif checkForString(word1) thenentry = makeEntryName(word1, languageCode)linkText = word1endlocal outif languageCode and entry and linkText thenout = linkToWiktionary(entry, linkText, languageCode) elseif entry and linkText thenout = linkToWiktionary(entry, linkText)elseout = '<span style="font-size: smaller;">[text?]</span>'endif out and errorText thenreturn out and out .. errorTextelsereturn errorText or error("The function wikt generated nothing")endendreturn p
🔥 Top keywords: ପ୍ରଧାନ ପୃଷ୍ଠାମୋହନ ଚରଣ ମାଝୀମନମୋହନ ସାମଲବିଶେଷ:ଖୋଜନ୍ତୁଲକ୍ଷ୍ମୀକାନ୍ତ ମହାପାତ୍ରଗଙ୍ଗାଧର ମେହେରଗୋପବନ୍ଧୁ ଦାସଓଡ଼ିଆ ଭାଷାରଜମଧୁସୂଦନ ଦାସଫକୀର ମୋହନ ସେନାପତିଜଗନ୍ନାଥ ମନ୍ଦିରସାରଳା ଦାସବନ୍ଦେ ଉତ୍କଳ ଜନନୀକୋଣାର୍କ ସୂର୍ଯ୍ୟ ମନ୍ଦିରଜଗନ୍ନାଥ ଦାସhjek3ମହାତ୍ମା ଗାନ୍ଧୀଦ୍ୱିତୀୟ ବିଶ୍ୱଯୁଦ୍ଧକୃଷ୍ଣଚନ୍ଦ୍ର ପାଣିଗ୍ରାହୀଉପେନ୍ଦ୍ର ଭଞ୍ଜଓଡ଼ିଆ ସାହିତ୍ୟସୁରେନ୍ଦ୍ର ମହାନ୍ତିପ୍ରତିଭା ରାୟଅନନ୍ତ ପଟ୍ଟନାୟକଓଡ଼ିଶାକୁନ୍ତଳା କୁମାରୀ ସାବତମୁଦ୍ରା ଚିହ୍ନଭି. କାର୍ତ୍ତିକେୟ ପାଣ୍ଡିଆନwiki.phtmlପଠାଣି ସାମନ୍ତଲିଙ୍ଗରାଜ ମନ୍ଦିରମଧୁସୂଦନ ରାଓରାଧାନାଥ ରାୟଜଗନ୍ନାଥବିଶେଷ:ନଗଦବଦଳସଚ୍ଚିଦାନନ୍ଦ ରାଉତରାୟଭାରତସିକ୍ଲ ସେଲ୍ ରୋଗ