Module:User:Wpi31/zh-translate

export = {}

local codes = { ["m"] = "cmn", ["c"] = "yue", ["c-t"] = "zhx-tai", ["g"] = "gan", ["h"] = "hak", ["j"] = "cjy", ["mb"] = "mnp", ["md"] = "cdo", ["mn"] = "nan", ["mn-t"] = "zhx-teo", ["w"] = "wuu", ["x"] = "hsn", }

local m_extract = require("Module:zh/extract")

local function make_trans(list, var) local r = {} for i in list do		r:insert(""..i.."") end return r:concat(", ") end

local function merge(a, b)	local result = {} local i = 1 while 1 do		if a[i] then result:insert(a[i]) end if b[i] then result:insert(b[i]) end if not (a[i] or b[i]) then break end i = i + 1 end return result end

function export.make(frame) local args = frame:getParent.args local t = {"* Chinese:\n"} local list = require("Module:zh/data/dial-syn/"..args[1]).list if list["Guangzhou"] or list["Hong Kong"] then t:insert("*: Cantonese: ") t:insert(make_trans(merge(list["Guangzhou"], list["Hong Kong"]), "c").."\n") end if list["Nanchang"] then t:insert("*: Gan: ") t:insert(make_trans(list["Nanchang"], "g").."\n") end if list["Meixian"] then t:insert("*: Hakka: ") t:insert(make_trans(list["Meixian"], "h").."\n") end if list["Taiyuan"] then t:insert("*: Jin: ") t:insert(make_trans(list["Taiyuan"], "j").."\n") end if list["Beijing"] or list["Taiwan"] then t:insert("*: Mandarin: ") t:insert(make_trans(merge(list["Beijing"], list["Taiwan"]), "m").."\n") end if list["Jian'ou"] then t:insert("*: Min Bei: ") t:insert(make_trans(list["Jian'ou"], 'mb').."\n") end if list["Fuzhou"] then t:insert("*: Min Dong: ") t:insert(make_trans(list["Fuzhou"], "md").."\n") end if list["Xiamen"] or list["Taipei"] then t:insert("*: Min Nan: ") t:insert(make_trans(merge(list["Xiamen"], list["Taipei"]), "mn").."\n") end if list["Taishan"] then t:insert("*: Taishanese: ") t:insert(make_trans(list["Taishan"], "c-t").."\n") end if list["Chaozhou"] then t:insert("*: Teochew: ") t:insert(make_trans(list["Chaozhou"], "mn-t").."\n") end if list["Shanghai"] then t:insert("*: Wu: ") t:insert(make_trans(list["Shanghai"], "w").."\n") end if list["Changsha"] then t:insert("*: Xiang: ") t:insert(make_trans(list["Changsha"], "x").."\n") end if #t == 1 then return error("Chinese dialect synonym table for "..args[1].."does not exist") end return t:concat("") end

return export