Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supposedly valid Language instances may have invalid tags #55

Open
dscorbett opened this issue Nov 12, 2021 · 0 comments
Open

Supposedly valid Language instances may have invalid tags #55

dscorbett opened this issue Nov 12, 2021 · 0 comments

Comments

@dscorbett
Copy link

dscorbett commented Nov 12, 2021

Language.get normalizes case and enforces syntactic validity whereas Language.make doesn’t. This causes some discrepancies. I presume that a user is not supposed to have to worry about case or syntactic validity once they have a valid (in the sense of is_valid) Language object.

If Language is valid, its tag should presumably be valid. This is not always true.

>>> lang = Language.make(language='Latn')
>>> lang.is_valid()
True
>>> tag_is_valid(lang.to_tag())
False
>>> 
>>> lang = Language.make(script='Qaaa..Qabx')
>>> lang.is_valid()
True
>>> tag_is_valid(lang.to_tag())
False
>>> 
>>> lang = Language.make(extensions='t-fr')
>>> lang.is_valid()
True
>>> tag_is_valid(lang.to_tag())
False
>>> 
>>> lang = Language.make(extensions=['a'])
>>> lang.is_valid()
True
>>> tag_is_valid(lang.to_tag())
False
>>> 
>>> lang = Language.make(language='x-') 
>>> lang.is_valid()
True
>>> tag_is_valid(lang.to_tag())
False

Round-tripping a valid Language through its tag should presumably return an equivalent Language. This is not always true.

>>> lang = Language.make(language='FR')
>>> lang.is_valid()
True
>>> lang == Language.get(lang.to_tag(), normalize=False)
False

Alternatively, maybe it is the user’s responsibility to normalize case and check for syntactic validity before calling Language.make. I don’t think the documentation actually says that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant