Skip to content

Add v1.2 draft schema with BCP 47 language codes - #90

Merged
bpepple merged 2 commits into
masterfrom
v1.2-language-code
Oct 23, 2026
Merged

bpepple merged 2 commits into
masterfrom
v1.2-language-code

Conversation

@bpepple

@bpepple bpepple commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #89. The languageCode type only allowed two lowercase letters ([a-z][a-z]), so the lang attribute on Series and AlternativeName rejected:

  • Three-letter codes for languages with no two-letter code (e.g. fil, yue)
  • Tags with region or script subtags (e.g. pt-BR, zh-Hant)

Changes

  • Start a drafts/v1.2 schema, copied from v1.1.
  • In v1.2, change the languageCode pattern 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})*
  • The type stays based on xs:string rather than xs:language. xs:language collapses whitespace before checking the pattern, which would let values like " en" validate while the raw attribute still holds the spaces.
  • Add v1.2 tests covering valid tags (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 lang value 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 lang is 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 lang as 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.

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
@bpepple bpepple self-assigned this Oct 20, 2026
@bpepple bpepple added bug Something isn't working non-breaking The change will generate a new minor version of the schema labels Oct 20, 2026
@bpepple

bpepple commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Anyone want to give this PR a sanity look?

@bpepple
bpepple requested a review from majora2007 October 22, 2026 12:03
Comment thread drafts/v1.2/MetronInfo.xsd Resolved
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.

@ajslater ajslater left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm i like accepting 3 letter codes.

@bpepple
bpepple merged commit a45f83d into master Oct 23, 2026
3 checks passed
@bpepple
bpepple deleted the v1.2-language-code branch October 23, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking The change will generate a new minor version of the schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Schema] Wrong languageCode definition

4 participants