پودمان:پارسیگوی
ظاهر
local p = {}
local l = {}
local random = require("پودمان:Random")
local math = require("پودمان:Math")
local string = require("پودمان:String")
local function isempty(s)
return s == nil or s == ''
end
function p.getRandomWord()
local myWords = mw.loadData("پودمان:پارسیگوی/داده")
local all_words = myWords.all_words
local lengthOfTable = GetTableLng(all_words)
local randomNumber = random.number({1,lengthOfTable, same='no'})
local selectedElement = all_words[randomNumber]
local formattedPersianWord = "«'''" .. selectedElement.persianWord .. "'''»"
--local formattedNonPersianWord = "'''" ..
if (isempty(selectedElement.WikiFaArticle)) then
formattedNonPersianWord = "«'''" .. selectedElement.nonPersianWord .. "'''»"
else
formattedNonPersianWord = "«'''" .. "[[" .. selectedElement.WikiFaArticle .. "|" .. selectedElement.nonPersianWord .. "]]" .. "'''»"
end
return "به جای " .. formattedNonPersianWord .. " بگو " .. formattedPersianWord
end
function p.getWordAt(frame)
local myWords = mw.loadData("پودمان:پارسیگوی/داده")
local all_words = myWords.all_words
local lengthOfTable = GetTableLng(all_words)
local wordIndex = frame.args[1]
local selectedElement = all_words[tonumber(wordIndex)]
local formattedPersianWord = "«'''" .. selectedElement.persianWord .. "'''»"
--local formattedNonPersianWord = "'''" ..
if (isempty(selectedElement.WikiFaArticle)) then
formattedNonPersianWord = "«'''" .. selectedElement.nonPersianWord .. "'''»"
else
formattedNonPersianWord = "«'''" .. "[[" .. selectedElement.WikiFaArticle .. "|" .. selectedElement.nonPersianWord .. "]]" .. "'''»"
end
return "به جای " .. formattedNonPersianWord .. " بگو " .. formattedPersianWord
end
function GetTableLng(tbl)
local getN = 0
for n in pairs(tbl) do
getN = getN + 1
end
return getN
end
return p