请输入您要查询的百科知识:

 

词条 Module:Infobox road/abbrev/CAN
释义

local p = {}

local format = mw.ustring.format

local typesModule = require "Module:Infobox road/abbrev/defs"

Country = typesModule.Country

Type = typesModule.Type

Abbr = typesModule.Abbr

local abbrs = Country:new()

do -- Abbreviation definitions

    function abbrs:typeOverride(args)        local type = args.type        local province = args.province        if type == province then            return self["Hwy"]        else            return nil        end    end        do -- Provincial highways        local type = Type:new()        do            local types = {"Fwy", "Hwy", "PTH", "Route"}            for i,v in ipairs(types) do                abbrs[v] = type            end        end        do -- Hwy            local abbr = Abbr:new{formatStr = "Hwy %s"}            type["AB"] = abbr            type["YT"] = abbr            type["SK"] = abbr            type["NT"] = abbr        end -- Hwy        do -- Route            local provinces = {"QC", "NB", "PE", "NL"}            local abbr = Abbr:new{formatStr = "Route %s"}            for i,v in ipairs(provinces) do                type[v] = abbr            end        end -- Route        type["BC"] = Abbr:new{formatStr = "BC %s"}        type["MB"] = Abbr:new{formatStr = "PTH %s"}        type["ON"] = Abbr:new{formatStr = "Highway %s", exceptions={["QEW"] = "QEW"}}        do -- Nova Scotia            local function processTypeExceptions(exceptions, default, formatArgs)                return function (args)                    local formatArguments = {}                    for i,v in ipairs(formatArgs) do                        formatArguments[i] = args[v]                    end                    local type = args.type                    local formatStr = exceptions[type] or default                    args.override = format(formatStr, unpack(formatArguments))                end            end            local typeExceptions = {["Hwy"] = "Hwy %s", ["NS"] = "Hwy %s", ["PTH"] = "Hwy %s", ["Route"] = "Route %s"}            local preprocessor = processTypeExceptions(typeExceptions, '', {"route"})            type["NS"] = Abbr:new{formatStr = "%s", formatArgs = {"override"}, preprocessors = {preprocessor}}        end -- Nova Scotia    end -- Provincial highways        abbrs["TCH"] = Abbr:new{formatStr = "Hwy %s (TCH)"} -- Trans-Canada Highway        do -- Autoroutes        local abbr = Abbr:new{formatStr = "A-%s"}        abbrs["Autoroute"] = abbr        abbrs["A"] = abbr    end -- Autoroutes        abbrs["CR"] = Abbr:new{formatStr = "CR %s"} -- County roads        do -- Secondary Highways        local type = Type:new{["ON"] = Abbr:new{formatStr = "Hwy %s"}}        abbrs["Sec"] = type        abbrs["Secondary"] = type    end -- Secondary Highways        do -- Municipal roads        local function countyCheck(args)            local county = args.county            if county == "Kawartha Lakes" then                args.countyFormatArg = "K.L. "            else                args.countyFormatArg = ""            end        end        abbrs["MR"] = Abbr:new{formatStr = "%sRoad %s", formatArgs = {"countyFormatArg", "route"}, preprocessors = {countyCheck}}    end -- Municipal roads        abbrs["RR"] = Abbr:new{formatStr = "RR %s"} -- Regional roads    abbrs["Trunk"] = Type:new{["NS"] = Abbr:new{formatStr = "Trunk %s"}} -- Trunk highways    abbrs["PR"] = Abbr:new{formatStr = "PR %s"} -- Provincial roads    

end

p.abbrs = abbrs

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/23 21:23:37