Modul:translit-redirect

A Wikiszótárból, a nyitott szótárból
Ugrás a navigációhoz Ugrás a kereséshez

This module replaces transliteration modules that don't generate transliteration. It takes language and script code and redirects to the actual transliteration module that handles this combination of codes, using Module:translit-redirect/data. It has replaced transliteration modules like Module:pa-translit. A modul által kezelt átírású nyelvek: arámi (arc), ashokan prakrit (inc-ash), bhodzspuri (bho), blin (byn), északi kurd (kmr), inuktitut (iu), kasmíri (ks), khwarezmian (xco), kipchak (qwm), konkani (kok), középperzsa (pal), krí (cr), kurd (ku), laz (lzz), lomavren (rmi), (khb), nevari (new), óangol (ang), ógörög (grc), old marathi (omr), ónorvég (non), páli (pi), pandzsábi (pa), parthian (xpr), punic (xpu), sogdian (sog), szanszkrit (sa), udi (udi), wakhi (wbl) és western kayah (kyu).

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.

Examples[szerkesztés]

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
		local 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