first commit

This commit is contained in:
linkitapps
2026-09-14 23:22:10 +09:00
commit 9f9c8fb69b
4207 changed files with 1333187 additions and 0 deletions
@@ -0,0 +1,13 @@
import re
# Structurally validates BCP 47 language tags (RFC 5646).
# Accepts private-use tags (x-...) and standard tags (2-8 alpha + optional subtags).
# Does not validate subtags against the IANA registry.
_LANGUAGE_TAG_RE = re.compile(
r"^(x(-[a-zA-Z0-9]{1,8})+|[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*)$"
)
def is_valid_language_tag(tag):
"""Return True if tag is a structurally valid BCP 47 language tag."""
return isinstance(tag, str) and bool(_LANGUAGE_TAG_RE.match(tag))