模組討論:WikitextLC

页面内容不支持其他语言。
维基百科,自由的百科全书

加一点洋文的文档[编辑]

请求已处理

我给mw:Writing_systems#LanguageConverter加了行字,说可以用这玩意整个Lua的懒人接口。不过既然那么整了就得搞点洋文的文档了……

local p = {}

--- Construct an inline conversion from a table input.
-- @param content table of the form
--        { ["zh-cn"]='foobar', ["zh-tw"]='firecat', ["zh-hk"]='' }
-- @returns string
--       "-{zh-cn:foobar;zh-tw:firecat;zh-hk:<span></span>}-"
--
-- @fixme allow for generating output without "-{" "}-", so that
--        it can be used with the last three wrappers.
function p.selective( content )
    -- 内容略去
end

--- Write some text with a limited set of variants to convert to
--
-- @param content text to be written
-- @param variant a variant (string), or a list of variants
--        (semicolon-deliminated string, or table of strings)
-- @param[opt] force convert even under "zh" (no conversion) locale
function p.converted( content, variant, force )
    if type( variant ) == 'table' then
        variant = table.concat( variant, ';' )
    end
    return '-{' .. ( force and '' or 'zh;' ) .. variant .. '|' .. content .. '}-'
end

--- Wraps some "raw text" to not convert.
--
-- @fixme Is the "R" flag some undocumented/undefined no-op magic?
--        Are we using it instead of the old '-{' .. content .. '}-'
--        to avoid confusion caused by a flag in the "content"?
function p.raw( content )
    return '-{R|' .. content .. '}-'
end

--- Wraps a title conversion rule.
function p.title( content )
    return '-{T|' .. content .. '}-'
end

--- Wraps a (hidden) conversion rule definition.
function p.hidden( content )
    return '-{H|' .. content .. '}-'
end

return p

Fixme的问题顺便看一下吧。 --Artoria2e5 讨论要完整回覆请用ping 2018年4月30日 (一) 01:44 (UTC)[回复]

提供批量单向转换函数[编辑]

请求已拒绝

目前单向转换没有回落,用起来偶尔还是挺头疼的:写hk也要写mo,写cn也得要hans和sg。如果能提供一个生成多个单向转换的函数,应该可以方便一点。请加入以下内容:

-- Generates multiple monodirection conversions
-- (str, str, str[]) → str
function p.mono(source, target, variants)
	local tmp = {}
	for _, var in ipairs(variants) do
		-- A=>zh-tw:B
		table.insert(tmp, source .. '=>' .. var .. ':' .. target)
	end
	return table.concat(tmp, ';')
end

--Artoria2e5 讨论要完整回覆请用ping 2021年1月31日 (日) 09:26 (UTC)[回复]

  • (-)反对:部分字詞只適宜在一個顯示模式下轉換,其他顯示模式下都不應該轉換(例如「南韓」應該在中國大陸模式下轉換為「韓國」,但在其他模式下都不應該轉換,包括新加坡簡體和大馬簡體)。請求進一步闡釋預期實際應用效果。SANMOSA SPQR 2021年1月31日 (日) 09:41 (UTC)[回复]
    • sanmosa,不少hk的单向转换都没有加入mo项目,{ type = 'item', original = 'crème brûlée', rule = '烤布蕾 => zh-cn:法式炖蛋; 烤布蕾 => zh-hk:焦糖布甸;'}正为一例。使用 Google 搜索就可以在各种美食点评网站上找到使用 hk 名称的澳门店铺。况且这只是方便批量生成的工具,具体同时出哪些 variant 是人类传入的参数决定的。我真的不懂你在反对什么。--Artoria2e5 讨论要完整回覆请用ping 2021年2月2日 (二) 13:55 (UTC)[回复]
      我反對的點在於有些時候單向轉換就是只能轉cn、不能轉sg和my;只能轉tw、不能轉hk和mo。上面的情況的單向轉換不在少數,這種批量生成的工具很容易誤用,你這樣無疑會衍生更嚴重的副作用。我認為應增加文字警示以提醒用戶。SANMOSA SPQR 2021年2月3日 (三) 00:13 (UTC)[回复]
  • 存在异议,暂关闭。请讨论得出结论后再提出编辑请求。--Tiger留言2021年2月22日 (一) 03:44 (UTC)[回复]