Module:Sandbox/Erutuon: Difference between revisions

Content deleted Content added
invalid if language subtag is missing; increment count for private-use subtag
"error" field
Line 361:
local subtags = mw.text.split(tag, "-")
-- This contains the special fields "countmatched_count" and "invalid".
-- "countmatched_count" tracks the number of subtags, "invalid" indicates that at least
-- one unparsable subtag was found. "error" indicates why the tag was
-- invalid.
-- All other fields are subtags.
local parsed_subtags = { countmatched_count = 0, invalid = false }
-- An array of patterns for each subtag, and a "type" field for the name
Line 413 ⟶ 414:
parsed_subtags[type] = subtag
last_matched_subtag_i = subtag_i
parsed_subtags.countmatched_count = parsed_subtags.countmatched_count + 1
elseif not subtag_info[index] then
break
Line 419 ⟶ 420:
end
if #subtags > parsed_subtags.countmatched_count then
-- Not all subtags were matched. The unmatched tail end of the tag
-- (after the subtag at the index last_matched_subtag_i) is a
Line 427 ⟶ 428:
parsed_subtags.private_use =
table.concat(subtags, "-", last_matched_subtag_i + 1)
parsed_subtags.countmatched_count = parsed_subtags.countmatched_count + 1
else
parsed_subtags.invalid = true
parsed_subtags.error = "invalid subtag"
end
end
Line 435 ⟶ 437:
if not parsed_subtags.language then
parsed_subtags.invalid = true
parsed_subtags.error = "no language"
end