local p = {}
local function isvalid(x)
if x and x ~= "" then
return x
end
return nil
end
local function full_temp(lang_code, lang_name, text)
local temp =
"{{رمز لغة واسمها" ..
"|" ..
lang_code ..
"|" .. --lang_name ..
"|" .. text .. --"|na=" .. lang_name ..
"}}"
mw.log(temp)
return mw.getCurrentFrame():preprocess(temp)
end
local function short_temp(lang_code, text)
return mw.getCurrentFrame():preprocess("{{رمز لغة" .. "|" .. lang_code .. "|" .. text .. "}}")
end
function p._main(datavalue, datatype, options)
local lang_code = datavalue.value.language
local text = datavalue.value.text
local lang_name = mw.language.fetchLanguageName(lang_code, "ar")
if lang_code == "mis" then -- Unsupported language
return text
end
if isvalid(options.langpref) then
if options.langpref == "justlang" then
return lang_name
elseif options.langpref == "langcode" then
return lang_code
else
if lang_code == options.langpref then
local valu = mw.text.tag("span", { title = lang_name }, text)
local lange = "(" .. lang_name .. ")"
if isvalid(options.formatting) == "text" or lang_name == "العربية" or lang_code == "ar" then
return text
elseif isvalid(options.showlang) then
return full_temp(lang_code, lang_name, text)
else
return short_temp(lang_code, text)
end
end
end
else
lange = "(" .. lang_name .. ")"
valu = mw.text.tag("span", { title = lang_name }, text)
if lang_name == "العربية" or lang_code == "ar" then
return text
elseif isvalid(options.showlang) then
return full_temp(lang_code, lang_name, text)
else
return short_temp(lang_code, text)
end
end
end
function p.main(frame)
return p._main({ language = frame.args["language"], text = frame.args["text"] }, frame.args["datatype"], frame.args)
end
return p