Module:Wikt-lang: Difference between revisions

Content deleted Content added
fix right-to-left; expand language tagging function along the lines of Wiktionary function; put text first in argument order; rename some functions and variables
determine code validity
Line 247:
 
function p.wikt(frame)
local codes = frame.args[1]
local validity = (find(codes, "^%s*%l%l%l?%s*$") or find(codes, "^%s*%l%l%l?-%u%l%l%l%s*$") ) and "correct capitalization" or (find(codes, "^%s*%a%a%a?%s*$") or find(codes, "^%s*%a%a%a?-%a%a%a%a%s*$") ) and "incorrect capitalization" or "invalid"
if validity == "invalid" then
error("Language or script code or codes in first parameter not recognized")
end
-- A three- or two-letter lowercase sequence at beginning of first parameter
local languageCode = match(frame.args[1]codes, "^%s*(%l%l%l)") or match(frame.args[1]codes, "^%s*(%l%l)")
-- One uppercase and three lowercase letters at the end of the first parameter
local scriptCode = match(frame.args[1]codes, "(%u%l%l%l)%s*$") or nil
local word1 = frame.args[2]
local word2 = frame.args[3]