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

Support Language Code validation #71

Open
insightindustry opened this issue Jan 9, 2021 · 0 comments
Open

Support Language Code validation #71

insightindustry opened this issue Jan 9, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@insightindustry
Copy link
Owner

It would be good to support the validation of Language Codes in line with ISO 639-1, ISO 639-2, and IETF BCP47, etc.

Given the mess in global language code standards, and the different schemas used in different contexts (i18n vs L10n, etc.) it'll be important to provide a pretty comprehensive implementation.

The basic syntax will need to be:

  • validators.language_code(value, ..., standard = None) which returns the validated language code where:
    • value may either be a direct language code in one of the standard schemas OR the "human readable" expansion of the language (e.g. "English" which would validate to "en", or "American English" (country + language) which would validate to "en_US".
    • standard indicates the standard against which it should be validated, but which defaults to validated against all standards
  • checkers.is_language_code(value) which validates against validators.language_code()
  • validators.language(value, ..., standard = None) which returns the validated human-readable language (e.g. "English" or "American English") with standard title-case applied:
    • value is a language code in one of the standard schemas (which can be narrowed down using standard) OR a human readable language (e.g. "english" or "American english")
    • standard indicates the standard schema against which it should be validated, but which defaults to validation against all standards
  • checkers.is_language(value) which validates against validators.language()
@insightindustry insightindustry added the enhancement New feature or request label Jan 9, 2021
@insightindustry insightindustry added this to the 1.6.0 milestone Jan 9, 2021
@insightindustry insightindustry self-assigned this Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant