Module:Translit-redirect是什么意思_Module:Translit-redirect读音|解释_Module:Translit-redirect同义词|反义词

Module:Translit-redirect

此模块用于取代不生成转写的转写模块。它采用语言和脚本代码,并使用 Module:translit-redirect/data 重定向到处理这种代码组合的实际音译模块。它已经取代了像 Module:pa-translit 这样的转写模块。使用此模块处理转写的语言包括:上古格鲁吉亚语 (oge), 上古马拉地语 (omr), 中古波斯语 (pal), 亚拉姆语 (arc), 信德语 (sd), 傣仂语 (khb), 克什米尔语 (ks), 克里语 (cr), 博杰普尔语 (bho), 古希腊语 (grc), 古旁遮普语 (inc-opa), 古英语 (ang), 古诺尔斯语 (non), 喀奇语 (kfr), 因纽特语 (iu), 图陆语 (tcy), 夏尔巴语 (xsr), 多格拉语 (doi), 孔卡尼语 (kok), 安息语 (xpr), 尼瓦尔语 (new), 巴利语 (pi), 布匿语 (xpu), 拉兹语 (lzz), 旁遮普语 (pa), 普拉克里特语 (inc-pra), 曼尼普尔语 (mni), 梵语 (sa), 钦察语 (qwm), 比林语 (byn), 沙拉基语 (skr), 洛马夫伦语 (rmi), 乌迪语 (udi), 瓦尔哈迪语 (vah), 瓦罕语 (wbl), 粟特语 (sog), 罗兴亚语 (rhg), 腓尼基语 (phn), 花剌子模语 (xco), 西克耶语 (kyu), 迪维希语 (dv), 迈蒂利语 (mai), 阿输迦普拉克里特语 (inc-ash), 马拉地语 (mr), 马瓦里语 (mwr).

Using a single module to redirect to other transliteration modules will save some Lua memory on pages that tend to go over the memory limit. Also, the template that generates documentation for transliteration modules ({{translit module documentation}}) can only discover that a language uses a transliteration module, and list that language on the transliteration module's documentation page, if the transliteration module is listed either in the language's data file, or in Module:translit-redirect/data.

示例

pa (Punjabi) uses this module to redirect to the correct transliteration module for whatever script is being used.


local export = {}

function export.tr(text, lang, sc, debug_mode)
	if not sc then
		sc = require("Module:scripts").findBestScript(text, require("Module:languages").getByCode(lang)):getCode()
	end
	
	local language_data = mw.loadData("Module:translit-redirect/data")[lang]
	
	if language_data then
		script_data = language_data[sc]
		
		if script_data then
			if script_data.module then
				local success, translit_module = pcall(require, "Module:" .. script_data.module)
			
				if success then
					return translit_module.tr(text, lang, sc, debug_mode)
				else
					error(translit_module)
				end
			else
				return nil
			end
		else
			require("Module:debug").track{
				"translit-redirect/incorrect-script/" .. lang,
				"translit-redirect/incorrect-script/" .. lang .. "/" .. sc,
			}
			mw.log("script code (" .. sc .. ") for language code " .. lang .. " not found in Module:translit-redirect/data; text: " .. text)
		end
	end
end

return export