Module:Sandbox/Nathan fraignt/Names

local p = {}

local dutchWordsArray = {"van", "der", "de", "den"} local dutchWordsArray_idx = {} for i,v in ipairs(dutchWordsArray) do dutchWordsArray_idx[v] = i end

local spanishAccentsArray = {"ó","á","é","í","ú", "ñ"} local spanishAccentsArray_idx = {} for i,v in ipairs(spanishAccentsArray) do spanishAccentsArray_idx[v] = i end

-- This is by no means a complete list. local chineseNamesArray = {"Chen", "Ching", "Li", "Chan", "Cheung", "Tsi-ang", "Cho", "Chiu", "Choi, Chow", "Fok", "Fu", "Hui", "Ho", "Kao", "Kwok", "Kwong", "Kwan", "Lau", "Lam", "Ma", "Ng", "Siu", "Tam", "Tang", "To"} local chineseNamesArray_idx = {} for i,v in ipairs(chineseNamesArray) do chineseNamesArray_idx[v] = i end

-- es, nl, zh, us

p.getNames = function(frame) local getFormat = function(nf_name) -- Spanje local test = "" for letter in string.gmatch(nf_name, "%a") do			if spanishAccentsArray_idx[letter] then return "es" end -- test = test .. "-" .. letter test = test .. letter end -- Dutch for word in string.gmatch(nf_name, "%w+" ) do			if dutchWordsArray_idx[word] then return "nl" end end -- Chinese for word in string.gmatch(nf_name, "%w+" ) do			if chineseNamesArray_idx[word] then return "zh" end end -- Default: US		return test end local nf_name = frame.args.name or "" local format = frame.args.format or getFormat(nf_name) return format end return p