feat(core): add preferred language column to user - #581
Open
abdulrafey1 wants to merge 2 commits into
Open
Conversation
NULL means the user never chose, so the platform default can change later without overriding anyone who actively picked English. resolve_language also falls back when a stored tag has left the allowlist, so a language we withdraw stops being handed back to users who had already selected it. resolve_language takes the tag itself rather than a User. Its only input was ever user.language, and taking the User dragged sparkth.core.models.user into the transitive import graph of the sparkth.lib.language façade — a public surface that now needs nothing but the standard library and core config. Adds the sparkth.lib.language facade entry to the generated API reference. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Nullable BCP 47 tag, max length 35 (the practical registry ceiling). 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
Stores a per-user preferred language and adds the resolver that turns a stored preference into the tag that applies.
Changes
user.languageBCP 47 columnresolve_language(tag)insparkth/core/language.py, exposed through the newsparkth/lib/language.pyfaçadeuser.languageHow to Test
make migrations— the new revision applies cleanly.uv run pytest tests/core/test_language.py -q— passes, covering both fallback cases.\d "user"in psql showslanguage | character varying(35) | nullable.Notes
Migration required (
0a2dfb2685ad). No API change — this PR is deliberately inert:languageis not exposed on any schema or endpoint yet, andresolve_languagehas no production caller.NULLmeans the user never chose, kept distinct from an explicit"en"so the platform default can change later without overriding anyone who actively picked English.resolve_languagealso falls back when a stored tag has since left the allowlist, so a language withdrawn for poor output quality stops being handed back to users who had already selected it.This description was written with the assistance of an LLM (Claude).