feat(core): add supported languages and DEFAULT_LANGUAGE setting - #580
Open
abdulrafey1 wants to merge 1 commit into
Open
feat(core): add supported languages and DEFAULT_LANGUAGE setting#580abdulrafey1 wants to merge 1 commit into
abdulrafey1 wants to merge 1 commit into
Conversation
Introduces the BCP 47 allowlist (en/es/fr) and the platform default used when a user has not chosen a language. The default is validated against the allowlist so a typo fails at startup instead of silently being accepted. Membership is expressed once, as is_supported_language, and the DEFAULT_LANGUAGE validator calls it rather than repeating the containment check. Both edges of the allowlist — the platform default and, later, a user's own tag — therefore answer to the same rule and cannot drift apart if it ever grows case folding or subtag stripping. Matching is exact and case-sensitive today: "en-US" and "EN" are unsupported, not normalised to "en". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the supported-language allowlist and the platform-wide
DEFAULT_LANGUAGEsetting that later work reads from.Changes
LanguageInfo,SUPPORTED_LANGUAGES(en/es/fr) andis_supported_languagetosparkth/core/config.pySettings.DEFAULT_LANGUAGE, validated against the allowlist at startupDEFAULT_LANGUAGEin the configuration reference and add it to.envHow to Test
uv run pytest tests/core/test_language.py -q— 8 tests pass.DEFAULT_LANGUAGE=klingonin.envand start the app: it fails at startup withDEFAULT_LANGUAGE must be one of: en, es, frrather than accepting the value.DEFAULT_LANGUAGE=enand confirm the app boots.Notes
New env var:
DEFAULT_LANGUAGE(defaults toen, committed in.env). No migration, no API change.Tags are BCP 47 (RFC 5646) and hyphenated — the form
HTML lang,Accept-Languageand the JSIntlAPI consume. The list is deliberately short: LLM output quality varies by language, so a language is added only once generated content in it has been reviewed by a speaker.is_supported_languagelives beside the allowlist so the membership rule has exactly one expression —Settings.DEFAULT_LANGUAGE's validator reuses it, which stops the platform default from ever accepting a value the API would reject.This description was written with the assistance of an LLM (Claude).