Difference between revisions 18626589 and 18626590 on frwiktionary

local export = {}

-- Detect the script based on the first alphabetical characters of a string
function export.detect_script(text, lang)
	if type(lang) == "string" then
		lang = require("Module:languages").getLanguageByCode(lang)
	end
	
	local m_scripts = mw.loadData("Module:scripts/tempdata")
	local scripts = mw.loadData("Module:languages/alldata")[lang:getCode()].scripts
	local scFix = false
	
	-- Does this language have more than one script?
	-- If not, we can bypass the detection for a speed bonus.
	-- But always do the detection if the script is "None" or "Zyyy"
	if not (scripts[2] or scripts[1] == "None" or scripts[1] == "Zyyy") then
(contracted; show full)		i = i + 1
		cat = args[i]
	end
	
	return export.format_categories(categories, lang, sort_key)
end

return export