導覽
近期變更
隨機頁面
新手上路
新頁面
優質條目評選
繁體
不转换
简体
繁體
18.223.159.143
登入
工具
閱讀
檢視原始碼
特殊頁面
頁面資訊
求真百科歡迎當事人提供第一手真實資料,洗刷冤屈,終結網路霸凌。
檢視 模块:地区用词 的原始碼
←
模块:地区用词
前往:
導覽
、
搜尋
由於下列原因,您沒有權限進行 編輯此頁面 的動作:
您請求的操作只有這個群組的使用者能使用:
用戶
您請求的操作只有這個群組的使用者能使用:
管理員
您可以檢視並複製此頁面的原始碼。
local p = {} local variants = { cn = 'hans', hk = 'hant', mo = 'hant', -- my = 'hans', sg = 'hans', tw = 'hant', } local lc = require( 'Module:WikitextLC' ) function p.main( frame ) local args = frame.args local values = {} -- dict<region:string> => <script:string, term:int>, -- where "term" is the index of the relevant string in "terms" local terms = {} -- table of term objects: -- regions: table<region:string>, regions that use this term -- hans, hant: string, term in different scripts -- fill region values, simp and trad, from explicit definitions for region, defaultScript in pairs( variants ) do if args['zh-hans-' .. region] ~= '' or args['zh-hant-' .. region] ~= '' or args['zh-' .. region] ~= '' then local term = { regions = { region } } if args['zh-hans-' .. region] ~= '' then term.hans = args['zh-hans-' .. region] elseif args['zh-' .. region] ~= '' then term.hans = lc.converted( args['zh-' .. region], 'zh-hans' ) else term.hans = lc.converted( args['zh-hant-' .. region], 'zh-hans' ) end if args['zh-hant-' .. region] ~= '' then term.hant = args['zh-hant-' .. region] elseif args['zh-' .. region] ~= '' then term.hant = lc.converted( args['zh-' .. region], 'zh-hant' ) else term.hant = lc.converted( args['zh-hans-' .. region], 'zh-hant' ) end table.insert( terms, term ) values[region] = { script = defaultScript, term = #terms } end end -- link up "equiv" aliases for missing regions for region, defaultScript in pairs( variants ) do if values[region] == nil and values[args['equiv-' .. region]] ~= nil then table.insert( terms[values[args['equiv-' .. region]].term].regions, region ) values[region] = { script = defaultScript, term = values[args['equiv-' .. region]].term } end end local localName = {} for region, value in pairs( values ) do localName['zh-' .. region] = terms[value.term][value.script] end localName = args.beforeTerm .. lc.selective( localName ) .. args.afterTerm local foreignName = {} for region, script in pairs( variants ) do local snippets = {} for _, term in pairs( terms ) do local termRegions = {} for _, termRegion in pairs( term.regions ) do if not args.stripLocal or args.stripLocal == '' or termRegion ~= region then table.insert( termRegions, termRegion ) end end if #termRegions > 0 then table.sort( termRegions ) local maybeNameKey = 'name-' .. table.concat( termRegions, '-' ) local name if args[maybeNameKey] and args[maybeNameKey] ~= '' then name = args[maybeNameKey] else local names = {} for _, termRegion in pairs( termRegions ) do table.insert( names, args['name-' .. termRegion] ) end name = mw.text.listToText( names, args.nameComma, args.nameLastComma ) end name = lc.converted( name .. args.colon, 'zh-' .. region ) table.insert( snippets, name .. args.beforeTerm .. term[script] .. args.afterTerm ) end end foreignNameText = mw.text.listToText( snippets, lc.converted( args.comma, 'zh-' .. region ), lc.converted( args.lastComma, 'zh-' .. region ) ) if foreignNameText ~= '' then local openBracket = "" local closeBracket = "" if args.showLocal and args.showLocal ~= 'no' then openBracket = lc.converted( args.openBracket, 'zh-' .. region ) closeBracket = lc.converted( args.closeBracket, 'zh-' .. region ) end foreignNameText = openBracket .. foreignNameText .. closeBracket end foreignName['zh-' .. region] = foreignNameText end foreignName = lc.selective( foreignName ) ret = '' if args.showLocal and args.showLocal ~= 'no' then ret = ret .. localName .. args.afterLocal end if args.showForeign and args.showForeign ~= 'no' then ret = ret .. foreignName end return ret end return p
此頁面使用了以下模板:
模块:地区用词/doc
(
檢視原始碼
)
返回「
模块:地区用词
」頁面