全站通知:
模块:Expanded/i18n
刷
历
编
跳到导航
跳到搜索
local Utils = require("Module:Utils")
local ZH = Utils.LazyLoad("Module:Expanded/i18n/zh", true)
local EN = Utils.LazyLoad("Module:Expanded/i18n/en", true)
local p = {}
local function getArg(input)
if type(input) == "string" then
return input
end
return input.args[1] or input:getParent().args[1]
end
local function cleanKey(str)
local match = string.match(str, "{{i18n:(.-)}}")
if match then
return match
else
return str
end
end
function p.getEnglishText(input)
local key = cleanKey(getArg(input))
return EN[key:lower()] or key
end
function p.getChineseText(input)
local key = cleanKey(getArg(input))
return ZH[key:lower()] or key
end
-- =p.zh_string{args={"Gifts.Sophia.Loved"}}
function p.zh_string(frame)
local text = frame.args[1]
if not text then
return ""
end
local lowerText = string.lower(text)
local result = ZH[lowerText] or ""
result = result:gsub('@', '<span class="player-name">玩家名</span>')
return result
end
-- =p.getDefaultString{args={"<玩家名>"}}
function p.getDefaultString(frame)
local text = frame.args[1]
if not text then
return ""
end
local keyForText = nil
for key, value in pairs(ZH) do
if value == text then
keyForText = key
break
end
end
if keyForText then
return EN[keyForText] or ""
else
return ""
end
end
return p