মডিউল:LinkPhone

উইকিভ্রমণ থেকে

ব্যবহারের উদাহরণ[সম্পাদনা]

লেখা কোড ফলাফল
+1 234 567 890 {{#invoke:LinkPhone|LinkPhone|+1 234 567 890}} +১ ২৩৪ ৫৬৭ ৮৯০
+1 234-567-890 {{#invoke:LinkPhone|LinkPhone|+1 234-567-890}} +১ ২৩৪-৫৬৭-৮৯০
+1 234-567-890 ext 12 {{#invoke:LinkPhone|LinkPhone|+1 234-567-890 ext 12}} +১ ২৩৪-৫৬৭-৮৯০ ext ১২
+1 (234) 567 890 {{#invoke:LinkPhone|LinkPhone|+1 (234) 567 890}} +১ (২৩৪) ৫৬৭ ৮৯০
+1 234.567.890 {{#invoke:LinkPhone|LinkPhone|+1 234.567.890}} +১ ২৩৪.৫৬৭.৮৯০বিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ
234 567 890 {{#invoke:LinkPhone|LinkPhone|234 567 890}} ২৩৪ ৫৬৭ ৮৯০বিষয়শ্রেণী:অনুপস্থিত দেশের কোডসহ ফোন তালিকাভুক্তকরণ
+1 234 567 WIKI {{#invoke:LinkPhone|LinkPhone|+1 234 567 WIKI}} +১ ২৩৪ ৫৬৭ WIKI (9454)
+44 20 7890 1234 আসন-সংরক্ষণ, +44 20 7890 1235 সাধারণ জিজ্ঞাসা {{#invoke:LinkPhone|LinkPhone|+44 20 7890 1234 আসন-সংরক্ষণ, +44 20 7890 1235 সাধারণ জিজ্ঞাসা}} +৪৪ ২০ ৭৮৯০ ১২৩৪ আসন-সংরক্ষণবিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ, +৪৪ ২০ ৭৮৯০ ১২৩৫ সাধারণ জিজ্ঞাসাবিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ
+44 20 7890 1234 (আসন-সংরক্ষণ), +44 20 7890 1235 (সাধারণ জিজ্ঞাসা) {{#invoke:LinkPhone|LinkPhone|+44 20 7890 1234 (আসন-সংরক্ষণ), +44 20 7890 1235 (সাধারণ জিজ্ঞাসা)}} +৪৪ ২০ ৭৮৯০ ১২৩৪ (আসন-সংরক্ষণ), +৪৪ ২০ ৭৮৯০ ১২৩৫ (সাধারণ জিজ্ঞাসা)
+44 20 7890 1234, +44 20 7890 1235 {{#invoke:LinkPhone|LinkPhone|+44 20 7890 1234, +44 20 7890 1235}} +৪৪ ২০ ৭৮৯০ ১২৩৪, +৪৪ ২০ ৭৮৯০ ১২৩৫
+44 20 7890 1234 {{#invoke:LinkPhone|LinkPhone|''+44'' 20 7890 1234}} +৪৪ ২০ ৭৮৯০ ১২৩৪
+44 (0)234 567 890 {{#invoke:LinkPhone|LinkPhone|+44 (0)234 567 890}} +৪৪ (০)২৩৪ ৫৬৭ ৮৯০বিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ
0844 123 4567 (উচ্চ খরচ) {{#invoke:LinkPhone|LinkPhone|0844 123 4567 (উচ্চ খরচ)}} ০৮৪৪ ১২৩ ৪৫৬৭ (উচ্চ খরচ)
visites.csg@cnes.fr (museum and tours), csg-accueil@cnes.fr (rocket launches) {{#invoke:LinkPhone|LinkEmail|visites.csg@cnes.fr (museum and tours), csg-accueil@cnes.fr (rocket launches)}} visites.csg@cnes.fr (museum and tours), csg-accueil@cnes.fr (rocket launches)
খালি {{#invoke:LinkPhone|LinkPhone| }}

local i = {}
local convert = require('মডিউল:সংখ্যা রূপান্তরকারী').convert

function i.LinkOnePhone(txt, demo, fax, tollfree)
    local link = txt;
    local othertxt = "";
    local catprefix = '';
    local catMissingCountryCode = '';
    local catFormatIssue = '';
    local output;
    if demo == 'true' then
    	catprefix = ':';
    end
    -- any other text in brackets at the end is stored separately and ignored for the dialing number
    if mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%2") ~= txt then
        othertxt = mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%2");
        txt = mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%1");
    end
    -- Don't include "ext NNNN" in the link
    link = mw.ustring.gsub(txt, " +[Ee][Xx][Tt] +%d+$", "");
    -- Don't include " xNNNN" in the link
    link = mw.ustring.gsub(link, " +x%d+$", "");
    link = mw.ustring.gsub(link, " ", "");
    link = mw.ustring.gsub(link, "'", "");
    if link == "" then
        return "";
    end
    if mw.ustring.sub(link, 1, 1) ~= '+' and mw.ustring.len(link) > 4 then
    	catMissingCountryCode = '[[' .. catprefix .. 'বিষয়শ্রেণী:অনুপস্থিত দেশের কোডসহ ফোন তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ফোন নম্বরে দেশের কোড দেওয়া হয়নি">NOCC</span>';
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 3) == '800' then
           catMissingCountryCode = '';
        end
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 4) == '0508' then
           catMissingCountryCode = '';
        end
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 4) == '0800' then
           catMissingCountryCode = '';
        end
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 4) == '1300' then
           catMissingCountryCode = '';
        end
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 4) == '1800' then
           catMissingCountryCode = '';
        end
        if tollfree == 'yes' and mw.ustring.sub(link, 1, 5) == '01800' then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"উচ্চ খরচ") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"অতিরিক্ত চার্জ") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"প্রিমিয়াম") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"স্থানীয় হার") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"দেশের মধ্যে শুধু") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"দেশীয়") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"জরুরী") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"অ%-জরুরী") ~= nil then
           catMissingCountryCode = '';
        end
        if mw.ustring.match(mw.ustring.lower(othertxt),"অ%-ভৌগলিক নম্বর") ~= nil then
           catMissingCountryCode = '';
        end
    end
    if mw.ustring.match(link,"^%+[%d-() ]+$") ~= nil then
		output = '<span class="plainlinks nourlexpansion">';
		if fax == 'true' then
			output = output .. convert('bn', tostring(txt)) .. '</span>' .. othertxt;
		else
			output = output .. '[tel:' .. convert('en', tostring(link)) .. ' ' .. convert('bn', tostring(txt)) .. ']</span>' .. othertxt;
		end
    elseif mw.ustring.match(link,"^%+[%d%u- ]+$") ~= nil then
        local extra = mw.ustring.match(link, "%u[%d%u- ]+")
        link = mw.ustring.gsub(link, "[A-C]", "2");
        link = mw.ustring.gsub(link, "[D-F]", "3");
        link = mw.ustring.gsub(link, "[G-I]", "4");
        link = mw.ustring.gsub(link, "[J-L]", "5");
        link = mw.ustring.gsub(link, "[M-O]", "6");
        link = mw.ustring.gsub(link, "[P-S]", "7");
        link = mw.ustring.gsub(link, "[T-V]", "8");
        link = mw.ustring.gsub(link, "[W-Z]", "9");
        extra = mw.ustring.gsub(extra, "[A-C]", "2");
        extra = mw.ustring.gsub(extra, "[D-F]", "3");
        extra = mw.ustring.gsub(extra, "[G-I]", "4");
        extra = mw.ustring.gsub(extra, "[J-L]", "5");
        extra = mw.ustring.gsub(extra, "[M-O]", "6");
        extra = mw.ustring.gsub(extra, "[P-S]", "7");
        extra = mw.ustring.gsub(extra, "[T-V]", "8");
        extra = mw.ustring.gsub(extra, "[W-Z]", "9");
		output = '<span class="plainlinks nourlexpansion">';
		if fax == 'true' then
			output = output .. convert('bn', tostring(txt)) .. ' (' .. extra .. ')' .. '</span>' .. othertxt;
		else
			output = output .. '[tel:' .. convert('en', tostring(link)) .. ' ' .. convert('bn', tostring(txt)) .. ' (' .. extra .. ')' .. ']</span>' .. othertxt;
		end
    else
        output = convert('bn', tostring(txt)) .. othertxt;
        if mw.ustring.match('+' .. link,"^%+[%d-() ]+$") == nil then
            catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ফোন নম্বরে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
        end
    end
    if mw.ustring.match(link,"%(0%)") ~= nil then
        catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ফোন বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ফোন নম্বরে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
    end
    if mw.title.getCurrentTitle().namespace == 0 or demo == 'true' then
        output = output .. catFormatIssue .. catMissingCountryCode;
    end
    return output;
end

function i.LinkPhone(frame)
    local demo = frame.args["demo"] or '';
	local fax = frame.args["fax"] or '';
    local txtall = frame.args[1] or '' .. ',';
    local tollfree = frame.args["tollfree"] or '';
    local txt = "";
    local result = "";
    -- replace or / and with comma
    txtall = mw.ustring.gsub(txtall, " or %+", ", +");
    txtall = mw.ustring.gsub(txtall, " and %+", ", +");
    for txt in mw.ustring.gmatch(txtall, "([^,]+)") do
        result = result .. ", " .. i.LinkOnePhone(txt, demo, fax, tollfree)
    end
    result = mw.ustring.sub(result, 3, mw.ustring.len(result) );
    return result;
end 

function i.LinkOneEmail(txt, demo)
    local othertxt = "";
    local catprefix = '';
    local catFormatIssue = '';
    local output;
    if demo == 'true' then
    	catprefix = ':';
    end
    -- any other text in brackets at the end is stored separately and ignored for the dialing number
    if mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%2") ~= txt then
        othertxt = mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%2");
        txt = mw.ustring.gsub(txt, "(.*)( %(.*%))$", "%1");
    end
    txt = mw.ustring.gsub(txt, " ", "");
    output = '[mailto:' .. txt .. ' ' .. txt .. ']' .. othertxt;
    if mw.ustring.match(txt,"@.+@") ~= nil then
        catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ইমেইল বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ইমেইলে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
    end
    if mw.ustring.match(txt,"@[^.]+%.%.") ~= nil then
        catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ইমেইল বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ইমেইলে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
    end
    if mw.ustring.match(txt,"@") == nil then
        catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ইমেইল বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ইমেইলে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
    end
    if mw.ustring.match(txt,"@[^.]+%.[^.]+") == nil then
        catFormatIssue = '[[' .. catprefix .. 'বিষয়শ্রেণী:ইমেইল বিন্যাস সমস্যাসহ তালিকাভুক্তকরণ]]<span class="phoneinfo" style="display:none;" title="ইমেইলে বিন্যাসন সমস্যা রয়েছে">FORMAT</span>';
    end
    if mw.title.getCurrentTitle().namespace == 0 or demo == 'true' then
        output = output .. catFormatIssue;
    end
    return output;
end

function i.LinkEmail(frame)
    local demo = frame.args["demo"] or '';
    local txtall = frame.args[1] or '' .. ',';
    local txt = "";
    local result = "";
    -- replace semicolon with comma
    txtall = mw.ustring.gsub(txtall, "; ", ", ");
    for txt in mw.ustring.gmatch(txtall, "([^,]+)") do
        result = result .. ", " .. i.LinkOneEmail(txt, demo)
    end
    result = mw.ustring.sub(result, 3, mw.ustring.len(result) );
    return result;
end 

return i;