Repository navigation
Add v1.2 draft schema with BCP 47 language codes - #90
Merged
Merged
Conversation
The languageCode type only allowed two lowercase letters, so lang rejected three-letter codes (fil, yue) and tags with script or region subtags (pt-BR, zh-Hant). Metron itself stores codes such as pt-br and zh-hans, which fail validation against v1.0 and v1.1. Start a v1.2 draft from v1.1 and base languageCode on xs:language, requiring a 2-3 letter primary language subtag. Case is not enforced, per BCP 47. Every previously valid value remains valid. Fixes #89
This was referenced Oct 22, 2026
Member
Author
|
Anyone want to give this PR a sanity look? |
jyggen
reviewed
Oct 22, 2026
languageCode was based on xs:language, which collapses whitespace before checking the pattern. That let values like " en" and "en " validate even though the raw attribute still contained the spaces. Base the type on xs:string instead, which leaves whitespace in place. The existing pattern is stricter than the one xs:language applies, so no other checks are lost. Add tests for leading and trailing whitespace.
Buried-In-Code
approved these changes
Oct 23, 2026
ajslater
approved these changes
Oct 23, 2026
ajslater
left a comment
Contributor
There was a problem hiding this comment.
lgtm i like accepting 3 letter codes.
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #89. The
languageCodetype only allowed two lowercase letters ([a-z][a-z]), so thelangattribute onSeriesandAlternativeNamerejected:fil,yue)pt-BR,zh-Hant)Changes
drafts/v1.2schema, copied from v1.1.languageCodepattern to require a 2–3 letter language code at the start, followed by optional subtags:[a-zA-Z]{2,3}(-[a-zA-Z0-9]{1,8})*xs:stringrather thanxs:language.xs:languagecollapses whitespace before checking the pattern, which would let values like" en"validate while the raw attribute still holds the spaces.en,fil,pt-br,pt-BR,zh-Hant,sr-latn,es-419) and invalid ones (e,english,en_US,en-,pt--br," en","en ").v1.0 and v1.1 are unchanged.
Compatibility
This only loosens the schema: every
langvalue that is valid today stays valid. Case isn't enforced, as BCP 47 treats tags as case-insensitive, but the standard form (pt-BR,zh-Hant) is recommended.Software that reads or writes MetronInfo files and assumes
langis always two characters will need updating before using v1.2. In particular, darkseid's language validation will need changes; that's planned for the v1.2 release.Documentation Fixes
The documentation currently describes
langas a "2-letter language code (ISO 639-3)". ISO 639-3 codes are all three letters, and the schema has always enforced ISO 639-1. The docs will be updated to describe BCP 47 when v1.2 is released.