پرش به محتوا

پودمان:Infobox road/link/CAN

از ویکی‌پدیا، دانشنامهٔ آزاد
توضیحات پودمان[ایجاد] [پاکسازی]
local p = {}

local format = mw.ustring.format

local typesModule = require "Module:Infobox road/link/defs"
Country = typesModule.Country
Type = typesModule.Type
Link = typesModule.Link

local links = Country:new()
do -- Link definitions
    function links:typeOverride(args)
        local type = args.type
        local province = args.province
        if type == province then
            return self["Hwy"]
        else
            return nil
        end
    end
    
    function links:link(args)
        local type = self:type(args)
        return type and (type:link(args) .. self:dab(args)) or error("Invalid type", 0)
    end
    
    function links:dab(args)
        local dabArg = args.dab
        return dabArg and format(" (%s)", dabArg) or ""
    end
    
    do -- Provincial highways
        local type = Type:new()
        do
            local types = {"Fwy", "Hwy", "PTH", "Route", "TCH"}
            for i,v in ipairs(types) do
                links[v] = type
            end
        end
        type["AB"] = Link:new{formatStr = "Alberta Highway %route%"}
        type["BC"] = Link:new{formatStr = "British Columbia Highway %route%"}
        type["MB"] = Link:new{formatStr = "Manitoba Highway %route%"}
        type["NB"] = Link:new{formatStr = "New Brunswick Route %route%"}
        type["NL"] = Link:new{formatStr = "Newfoundland and Labrador Route %route%"}
        type["NS"] = Link:new{formatStr = "Nova Scotia [type|Route|Route|Highway] %route%"}
        type["ON"] = Link:new{formatStr = "Ontario Highway %route%", exceptions={["QEW"] = "Queen Elizabeth Way"}}
        type["PE"] = Link:new{formatStr = "Prince Edward Island Route %route%"}
        type["QC"] = Link:new{formatStr = "Quebec Route %route%"}
        type["SK"] = Link:new{formatStr = "Saskatchewan Highway %route%"}
    end -- Provincial highways
    
    do -- Autoroutes
        local link = Link:new{formatStr = "Quebec Autoroute %route%"}
        links["Autoroute"] = link
        links["A"] = link
    end -- Autoroutes
    
    links["MR"] = Link:new{formatStr = "%county% Road %route%"} -- Municipal roads
    
    do -- Secondary Highways
        local type = Type:new{["ON"] = Link:new{formatStr = "Ontario Highway %route%"}}
        links["Sec"] = type
        links["Secondary"] = type
    end -- Secondary Highways
    
    links["CR"] = Link:new{formatStr = "%county% County Road %route%"} -- County roads
    links["RR"] = Link:new{formatStr = "%county% Regional Road %route%"} -- Regional roads
    links["Trunk"] = Type:new{["NS"] = Link:new{formatStr = "Nova Scotia Trunk %route%"}} -- Trunk highways
    links["PR"] = Link:new{formatStr = "Manitoba Provincial Road %route%"} -- Provincial roads
    
end

p.links = links
return p