Content deleted Content added
"error" field |
place invalid tag suffix in "invalid" field, use "error" to indicate both that an error was present and the type of error |
||
Line 362:
-- This contains the special fields "matched_count" and "invalid".
-- "matched_count" tracks the number of subtags, "
-- tag is invalid (if applicable).
-- invalid.▼
-- order:
▲ -- All other fields are subtags.
-- "language", "script", "region", "variant", "private_use", "invalid"
local parsed_subtags = { matched_count = 0, invalid = false }▼
-- "invalid" is the portion of the tag after the last valid subtag (minus a
-- An array of patterns for each subtag, and a "type" field for the name
Line 425 ⟶ 428:
-- private-use subtag if it starts with "x". Otherwise, the tag is
-- invalid.
if subtags[last_matched_subtag_i + 1] == "x" then
parsed_subtags.private_use = suffix
▲ table.concat(subtags, "-", last_matched_subtag_i + 1)
parsed_subtags.matched_count = parsed_subtags.matched_count + 1
else
parsed_subtags.invalid =
parsed_subtags.error = "invalid subtag"
end
Line 436 ⟶ 439:
if not parsed_subtags.language then
parsed_subtags.error = "no language"
end
|