Skip to content

feat(core): add preferred language column to user - #581

Open
abdulrafey1 wants to merge 2 commits into
refey/feat/lang-02-core-configfrom
refey/feat/lang-03-user-column
Open

feat(core): add preferred language column to user#581
abdulrafey1 wants to merge 2 commits into
refey/feat/lang-02-core-configfrom
refey/feat/lang-03-user-column

Conversation

@abdulrafey1

Copy link
Copy Markdown
Contributor

What

Stores a per-user preferred language and adds the resolver that turns a stored preference into the tag that applies.

Changes

  • feat(core): add the nullable user.language BCP 47 column
  • feat(core): add resolve_language(tag) in sparkth/core/language.py, exposed through the new sparkth/lib/language.py façade
  • feat(migrations): add user.language
  • docs(core): add the language module to the generated Python API reference

How to Test

  1. make migrations — the new revision applies cleanly.
  2. uv run pytest tests/core/test_language.py -q — passes, covering both fallback cases.
  3. Confirm the column exists and is nullable: \d "user" in psql shows language | character varying(35) | nullable.

Notes

Migration required (0a2dfb2685ad). No API change — this PR is deliberately inert: language is not exposed on any schema or endpoint yet, and resolve_language has no production caller.

NULL means 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_language also 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).

abdulrafey1 and others added 2 commits August 7, 2026 23:29
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>
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

Successfully merging this pull request may close these issues.

1 participant