Module:scripts: Verskil tussen weergawes

Content deleted Content added
Pynappel (Besprekings | bydraes)
Nuwe bladsy geskep met 'local export = {} local Script = {} function Script:getCode() return self._code end function Script:getCanonicalName() return self._rawData.canonicalName end functio...'
 
Naudefj (Besprekings | bydraes)
Werk by vanaf en:
Lyn 44:
local name = self._rawData.canonicalName
-- If the name already has "script", "code" or "semaphore" in it, don't add it.
-- No names contain "script".
if name:find("[Ss]script$") or name:find("[Cc]ode$") or name:find("[Ss]emaphore$") then
return name
else
Line 133 ⟶ 134:
if not text or not lang or not lang.getScripts then
return export.getByCode("None")
end
local scripts = lang:getScripts()
if #not scripts == 1[2] then
return scripts[1]
end
Line 140 ⟶ 147:
hence Latin was returned as the script if "Latn" is one of the language's scripts.
]=]
text = mw.ustringstring.gsub(text, "&[a-zA-Z0-9]+;", "")
local scripts = lang:getScripts()
if #scripts == 1 then
return scripts[1]
end
-- Try to match every script against the text,
Line 154 ⟶ 155:
-- Get length of text minus any spacing or punctuation characters.
-- Counting instances of UTF-8 character pattern is faster than mw.ustring.len.
local _, length = mw.ustringstring.lengsub(mw.ustring.gsub(text, "[%s%p]+", ""), "[\1-\127\194-\244][\128-\191]*", "")
if length == 0 then