Jump to content

ମଡ୍ୟୁଲ:ConvertDigit

ଉଇକିପାଠାଗାର‌ରୁ

ବ୍ୟବହାର

[ସମ୍ପାଦନା]

see: Doc
ଅନ୍ୟ ଉଇକିରେ ଏହି କୋଡ଼

{{#invoke:ConvertDigit|main|<!-- your text here -->}}
ଉଦାହରଣ: {{#invoke:ConvertDigit|En2ordigit|16:25, 3 April 2013 (UST)}} ଲେଖିଲେ, ଦେଖାଯିବ "୧୬:୨୫, ୩ April ୨୦୧୩ (UST)"
ଉଦାହରଣ: {{#invoke:ConvertDigit|Or2endigit|୧୬:୨୫, ୩ April ୨୦୧୩ (UST)}} ଲେଖିଲେ, ଦେଖାଯିବ "16:25, 3 April 2013 (UST)"
ଉଦାହରଣ: {{#invoke:ConvertDigit|main|16:25, 3 April 2013 (UST)}} ଲେଖିଲେ, ଦେଖାଯିବ "୧୬:୨୫, ୩ ଅପ୍ରେଲ ୨୦୧୩ (UST)"

ଆହୁରି ଦେଖନ୍ତୁ

[ସମ୍ପାଦନା]

ଏହି ମଡ୍ୟୁଲ ବ୍ୟବହାର ହେଇଛି

[ସମ୍ପାଦନା]

ଏହି ମଡ୍ୟୁଲ ବ୍ୟବହାର ହେଇନାହିଁ

[ସମ୍ପାଦନା]

-- First, define a table of text to search for, and what to convert it to.
local convertDigitOnly = {
   ['0'] = '୦',
   ['1'] = '୧',
   ['2'] = '୨',
   ['3'] = '୩',
   ['4'] = '୪',
   ['5'] = '୫',
   ['6'] = '୬',
   ['7'] = '୭',
   ['8'] = '୮',
   ['9'] = '୯',
}

local Odia2EngDigitOnly = {
   ['୦'] = '0',
   ['୧'] = '1',
   ['୨'] = '2',
   ['୩'] = '3',
   ['୪'] = '4',
   ['୫'] = '5',
   ['୬'] = '6',
   ['୭'] = '7',
   ['୮'] = '8',
   ['୯'] = '9',
}

local conversionTable = {
   ['January'] = 'ଜାନୁଆରୀ',
   ['February'] = 'ଫେବୃଆରୀ',
   ['March'] = 'ମାର୍ଚ୍ଚ',
   ['April'] = 'ଅପ୍ରେଲ',
   ['May'] = 'ମଇ',
   ['June'] = 'ଜୁନ',
   ['July'] = 'ଜୁଲାଇ',
   ['August'] = 'ଅଗଷ୍ଟ',
   ['September'] = 'ସେପ୍ଟେମ୍ବର',
   ['October'] = 'ଅକ୍ଟୋବର',
   ['November'] = 'ନଭେମ୍ବର',
   ['December'] = 'ଡିସେମ୍ବର',
   ['0'] = '୦',
   ['1'] = '୧',
   ['2'] = '୨',
   ['3'] = '୩',
   ['4'] = '୪',
   ['5'] = '୫',
   ['6'] = '୬',
   ['7'] = '୭',
   ['8'] = '୮',
   ['9'] = '୯',
}

-- Then we define a table to hold our function
local p = {}

-- define a function that converts english digits to Odia digits only nothing else.
function p.En2ordigit(frame)
    local s = frame.args[1] -- This gets the first positional argument.
    for en, odia in pairs(convertDigitOnly) do -- This converts every digit found in the table.
        s = mw.ustring.gsub(s, en, odia)
    end
    return s -- Get the result of the function.
end

-- define a function that converts Odia digits to English digits only nothing else.
function p.Or2endigit(frame)
    local s = frame.args[1] -- This gets the first positional argument.
    for en, odia in pairs(Odia2EngDigitOnly) do -- This converts every digit found in the table.
        s = mw.ustring.gsub(s, en, odia)
    end
    return s -- Get the result of the function.
end

-- Then we define a function that converts strings using conversionTable.
function p.main(frame)
    local s = frame.args[1] -- This gets the first positional argument.
    for en, odia in pairs(conversionTable) do -- This converts every string found in the table.
        s = mw.ustring.gsub(s, en, odia)
    end
    return s -- Get the result of the function.
end

return p -- Pass our table containing our function back to Lua.
-- Now we can call our function using {{#invoke:ConvertDigit|main|<!-- your text here 

-->}}.