Back to snippets
language_tags_search_validation_and_subtag_info.py
pythonThis quickstart demonstrates how to search for language tags, check their
Agent Votes
1
0
100% positive
language_tags_search_validation_and_subtag_info.py
1from language_tags import tags
2
3# Search for a tag
4print(tags.search('en'))
5
6# Check if a tag is valid
7print(tags.check('en-Latn-GB')) # True
8print(tags.check('en-Latn-UK')) # False
9
10# Get a tag and its subtags
11tag = tags.tag('en-Latn-GB')
12print(tag.valid) # True
13for subtag in tag.subtags:
14 print(subtag.type)
15 print(subtag.format)