可在模組:Road data/strings/TWN/doc建立此模組的說明文件

-- Tâi-oân
local TWN = {}
local format = mw.ustring.format
local function en_to_tiangan(num) -- Thian-kan
	local transfer = {a="kah",b="it",c="piáⁿ",d="teng",e="bō͘",f="kí",g="keⁿ"}
	if (transfer[string.sub(num,-1,-1)]== nil) then 
		return ""
	else
		return transfer[string.sub(num,-1,-1)]
	end
end

local function en_to_tiangan_cap(num) -- Thian-kan (tōa-siá)
	local transfer = {a="Kah",b="It",c="Piáⁿ",d="Teng",e="Bō͘",f="Kí",g="Keⁿ"}
	if (transfer[string.sub(num,-1,-1)]== nil) then 
		return ""
	else
		return transfer[string.sub(num,-1,-1)]
	end
end

---Kok-tō---
TWN.Fwy = {shield = {hook = "lowercase",---kok-tō
                     default = "TWHW%lowercase%.svg"},
                     
                   --kàn-sòaⁿ--
           link = {["1"] = "Tiong-san Ko-sok-kong-lō͘", 
           	       ["2"] = "Kok-tō 2 Hō (Tâi-oân)", 
           	       ["3"] = "Hok-ní-mô͘-sa Ko-sok-kong-lō͘",
           	       ["4"] = "Kok-tō 4 Hō (Tâi-oân)", 
           	       ["5"] = "Chiúⁿ Ūi-súi Ko-sok-kong-lō͘", 
           	       ["6"] = "Chúi-soa-liân Ko-sok-kong-lō͘",
           	       ["7"] = "Kok-tō 7 Hō (Tâi-oân)", 
           	       ["8"] = "Kok-tō 8 Hō (Tâi-oân)", 
           	       ["9"] = "Kok-tō 9 Hō (Tâi-oân)",
                   ["10"] = "Kok-tō 10 Hō (Tâi-oân)",
                   --chi-sòaⁿ--
                   ["1a"] = "Kok-tō 1 Hō Kah-sòaⁿ", 
                   ["2a"] = "Kok-tō 2 Hō Kah-sòaⁿ", 
                   ["3a"] = "Kok-tō 3 Hō Kah-sòaⁿ"},
                   
                 --kàn-sòaⁿ--         
          abbr = {["1"] = "Kok-tō 1 Hō", 
          	      ["2"] = "Kok-tō 2 Hō", 
          	      ["3"] = "Kok-tō 3 Hō", 
          	      ["4"] = "Kok-tō 4 Hō", 
          	      ["5"] = "Kok-tō 5 Hō",
                  ["6"] = "Kok-tō 6 Hō", 
                  ["7"] = "Kok-tō 7 Hō", 
                  ["8"] = "Kok-tō 8 Hō", 
                  ["9"] = "Kok-tō 9 Hō", 
                  ["10"] = "Kok-tō 10 Hō",
                 --chi-sòaⁿ--
                  ["1a"] = "Kok-tō 1 Hō Kah-sòaⁿ", 
                  ["2a"] = "Kok-tō 2 Hō Kah-sòaⁿ", 
                  ["3a"] = "Kok-tō 3 Hō Kah-sòaⁿ"},
          width = "expand"}

TWN.Freeway = TWN.Fwy
TWN.NH = TWN.Fwy
---(khok-chhiong) Kok-tō choân-miâ---
TWN["Fwy-ALL"] = {shield = {hook = "lowercase",
                     default = "TWHW%lowercase%.svg"},
                   --kàn-sòaⁿ--
           link = {["1"] = "Tiong-san Ko-sok-kong-lō͘", --中山高速公路
           	       ["2"] = "Thô-hn̂g Khoân-sòaⁿ", --桃園環線
           	       ["3"] = "Hok-ní-mô͘-sa Ko-sok-kong-lō͘", --福爾摩沙高速公路
           	       ["4"] = "Tâi-tiong Khoân-sòaⁿ",  --台中環線
          	       ["5"] = "Chiúⁿ Ūi-súi Ko-sok-kong-lō͘", --蔣渭水高速公路
           	       ["6"] = "Chúi-soa-liân Ko-sok-kong-lō͘", --水沙連高速公路
           	       ["7"] = "Ko-hiông-káng Tang-pêng Liân-gōa Ko-sok-kong-lō͘", --高雄港東爿聯外高速公路
           	       ["8"] = "Tâi-lâm Chi-sòaⁿ",  --台南支線
                   ["10"] = "Ko-hiông Chi-sòaⁿ", --高雄支線
                   --chi-sòaⁿ--
                   ["1a"] = "Thô-hn̂g Hâng-khong-siâ Pak-pêng Liân-gōa Ko-sok-kong-lō͘", --桃園航空城北爿聯高速公路
                   ["2a"] = "Tōa-hn̂g Chi-sòaⁿ", --大園支線
                   ["3a"] = "Tâi-pak Liân-lo̍k-sòaⁿ"}, --台北聯絡線
                 
                   --kàn-sòaⁿ--
        	abbr = {["1"] = "Tiong-san Ko-sok-kong-lō͘", 
           	       ["2"] = "Thô-hn̂g Khoân-sòaⁿ",
           	       ["3"] = "Hok-ní-mô͘-sa Ko-sok-kong-lō͘",
           	       ["4"] = "Tâi-tiong Khoân-sòaⁿ", 
          	       ["5"] = "Chiúⁿ Ūi-súi Ko-sok-kong-lō͘", 
           	       ["6"] = "Chúi-soa-liân Ko-sok-kong-lō͘",
           	       ["7"] = "Ko-hiông-káng Tang-pêng Liân-gōa Ko-sok-kong-lō͘",
           	       ["8"] = "Tâi-lâm Chi-sòaⁿ", 
                   ["10"] = "Ko-hiông Chi-sòaⁿ",
                   --chi-sòaⁿ--
                   ["1a"] = "Thô-hn̂g Hâng-khong-siâ Pak-pêng Liân-gōa Ko-sok-kong-lō͘",
                   ["2a"] = "Tōa-hn̂g Chi-sòaⁿ",
                   ["3a"] = "Tâi-pak Liân-lo̍k-sòaⁿ"},
          width = "expand"}

TWN["Freeway-ALL"] = TWN["Fwy-ALL"]
TWN["NH-ALL"] = TWN["Fwy-ALL"]

---Séng-tō---
local ph_aux_number =  {"1a","1b","1c","1d","1e","1f","2a","2b","2c","2d","2e","2f","2g","3a","3b","3c","5a","5b","7a","7b","7c","7d",
						"8a","9a","9b","9c","9d","9e","10b","11a","11b","11c","13a","14a","14b","14c","14d","15a","17a","17b","19a",
						"20a","20b","21a","27a","61a","61b","62a","63a","68a","74a"}

local ph_link = {default = "Tâi-%route%-sòaⁿ"}
local ph_abbr = {default = "Tâi-%route%-sòaⁿ"}

for _, num in ipairs(ph_aux_number) do
	ph_link[num] = format("Tâi-%s-%s-sòaⁿ", string.sub(num,1,-2), en_to_tiangan(num))
	ph_abbr[num] = format("Tâi-%s-%s-sòaⁿ", string.sub(num,1,-2), en_to_tiangan(num))
end

TWN.PH = {shield = {hook = "lowercase",
                    default = "TW PHW%lowercase%.svg"},
           link = ph_link,
           abbr = ph_abbr,
	       width = "expand"}

---(khok-chhiong) Khoài-sok-kong-lō͘ choân-miâ---
TWN["PH-ALL"] = {shield = {hook = "lowercase",
                     default = "TW PHW%lowercase%.svg"},
           link = {default = "Tâi %route%-sòaⁿ", ["62a"] = "Tâi-62-kah-sòaⁿ"},            
           abbr = {["61"] = "Se-pō͘ Pin-hái Khoài-sok-kong-lō͘", --西部濱海快速公路
           	       ["62"] = "Bān-lí Sūi-pin Sòaⁿ", --萬里瑞濱線
           	       ["62a"] = "Ke-lâng Sūi-hong Sòaⁿ", --基隆瑞芳線
           	       ["63"] = "Tiong-tâu Kong-lō͘", --中投公路
           	       ["64"] = "Pat-lí Sin-tiàm Sòaⁿ", --八里新店線
           	       ["65"] = "Gō͘-kó͘ Thô͘-siâⁿ Sòaⁿ" , --五股土城線
           	       ["66"] = "Koan-im Tāi-khe Sòaⁿ", --觀音大溪線 
           	       ["68"] = "Lâm-liâu Tek-tang Sòaⁿ",  --南寮竹東線
                   ["72"] = "Āu-lâng Būn-chúi Sòaⁿ", --後龍汶水線
                   ["74"] = "Khoài-koan Bū-hong Sòaⁿ", --快官霧峰線
                   ["76"] = "Hàn-pó Chháu-tūn Sòaⁿ", --漢寶草屯線
                   ["78"] = "Tâi-se Kó͘-kheⁿ Sòaⁿ", --台西古坑線
                   ["82"] = "Tang-chio̍h Ka-gī Sòaⁿ", --東石嘉義線
                   ["84"] = "Pak-mn̂g Gio̍k-chéⁿ Sòaⁿ", --北門玉井線
                   ["86"] = "Tâi-lâm Koan-biō Sòaⁿ", --台南關廟線
                   ["88"] = "Ko-hiông Tiô-chiu Sòaⁿ"}, --高雄潮州線
          width = "expand"}

---Koān-chhī-tō---
local cr_number =  {city_main = {"101","102","103","104","105","106","107","108","109","110",
								 "111","112","113","114","115","116","118","121","125","127",
								 "129","132","136","165","171","172","173","174","175","176",
								 "177","178","180","181","182","183","186","188"},
					city_aux = {"101a","102a","103a","106a","107a","110a","112a","113a","132a",
								"171a","172a","173a","177a","178a","180a","183a","186a",
								"106b","110b","113b","171b","172b","183b",
								"113c"},
					county_aux = {"119a","124a","134a","135a","138a","139a","143a","144a","145a","146a","149a",
								  "151a","153a","154a","158a","159a","162a","185a","187a","189a","191a","192a",
								  "196a","199a","200a","204a",
								  "124b","124a","134b","139b","145b","149b","154b","158b","162b","187b","191b",
								  "124c","187c"}}

local function cr_link_format(types,num)
	local tiangan = en_to_tiangan_cap(num)
	local formats = {city_main = format("Chhī-tō %s Hō",num),
				 	 city_aux = format("Chhī-tō %s Hō #%s-sòaⁿ", string.sub(num,1,-2), tiangan),
					 county_aux = format("Koān-tō %s Hō #%s-sòaⁿ", string.sub(num,1,-2), tiangan)}
	return formats[types]
end

local function cr_abbr_format(types,num)
	local tiangan = en_to_tiangan_cap(num)
	local formats = {city_main = format("Chhī-tō %s Hō",num),
				 	 city_aux = format("Chhī-tō %s %s-sòaⁿ", string.sub(num,1,-2), tiangan),
					 county_aux = format("Koān-tō %s %s-sòaⁿ", string.sub(num,1,-2), tiangan)}
	return formats[types]
end

local cr_link = {default = "Koān-tō %route% Hō"}
local cr_abbr = {default = "Koān-tō %route% Hō"}

for _, types in ipairs({"city_main","city_aux","county_aux"}) do
	for _, num in ipairs(cr_number[types]) do
		cr_link[num] = cr_link_format(types,num)
		cr_abbr[num] = cr_abbr_format(types,num)
	end 
end

TWN.CR = {shield = {hook = "lowercase",
                    default = "TW CHW%lowercase%.svg"},
           link = cr_link,
           abbr = cr_abbr,
	       width = "expand"}

TWN.CH = TWN.CR

---(khok-chhiong) kan-taⁿ hián-sī "Koān-tō XXX"---
local cr2_link = {default = "Koān-tō %route% Hō"}
local cr2_abbr = {default = "Koān-tō %route% Hō"}

for _, types in ipairs({"city_aux","county_aux"}) do
	for _, num in ipairs(cr_number[types]) do
		cr2_link[num] = cr_link_format(types,num)
		cr2_abbr[num] = format("Koān-tō %s %s-sòaⁿ", string.sub(num,1,-2), en_to_tiangan_cap(num))
	end 
end

TWN.CR2 = {shield = {hook = "lowercase",
                    default = "TW CHW%lowercase%.svg"},
           link = cr2_link,
           abbr = cr2_abbr,
	       width = "expand"}

TWN.CH2 = TWN.CR2

---Hiong-khu-tō---
local county_en = {"TP","TY","HC","ML","TC","CH","NT","YL","CY","TN","KH","PT",
				   "IL","HL","TT","PH"}

local function county_abbr(cname) --choán-ōaⁿ ûi koān-chhī kán-chheng
	local tables = {TP="Pak",TY="Thô",HC="Tek",ML="Biâu",TC="Tiong",CH="Chiong",NT="Tâu",YL="Hûn",
					CY="Ka",TN="Lâm",KH="Ko",PT="Pîn",IL="Gî",HL="Hoa",TT="Tang",PH="Pêⁿ"}
	return tables[cname]
end

for _, cname in ipairs(county_en) do
	num = "%route%"
	TWN["TR"..cname] = {shield = format("TW THW%s%s.svg", string.lower(cname), num),
		                link = format("%s-%s-sòaⁿ", county_abbr(cname), num),
		                abbr = format("%s-%s-sòaⁿ", county_abbr(cname), num)}
end

return TWN