Module:languages: Difference between revisions

No edit summary
No edit summary
 
Line 1,021: Line 1,021:
-- Count characters by removing everything in the script's charset and comparing to the original length.
-- Count characters by removing everything in the script's charset and comparing to the original length.
local charset = sc.characters
local charset = sc.characters
local count = charset and length - ulen((ugsub(text, "[" .. charset .. "]+", ""))) or 0
local count = charset and length - ulen((ugsub(text, "[" .. charset:gsub("%]", "%%]") .. "]+", ""))) or 0


if count >= length then
if count >= length then
Line 1,918: Line 1,918:
-- Incomplete transliterations return nil.
-- Incomplete transliterations return nil.
local charset = sc.characters
local charset = sc.characters
if charset and umatch(text, "[" .. charset .. "]") then
if charset and umatch(text, "[" .. charset:gsub("%]", "%%]") .. "]") then
-- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are
-- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are
-- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None"
-- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None"