df4c91a586
- Fix detect_language() to safely handle unhashable session values and requests missing cookies/headers attributes (TypeError + AttributeError) - Add default English `_()` translation function to Jinja2 template environment globals so error pages always have it available - Fix app/main.py exception handlers to use a dedicated error templates instance with `_` registered, keeping it separate from view templates to avoid test patches breaking error rendering - Fix app/views/plans.py to import shared templates from app.views.base instead of creating its own Jinja2Templates instance - Make migration 029_add_user_language_preference idempotent: skip ALTER TABLE if user_profiles table does not exist - Update test_i18n.py expectations to reflect 31 supported languages - Create 21 missing translation files (nb, da, sv, fi, is, ga, lb, ca, cs, sk, hu, sl, hr, ro, bg, el, et, lv, lt, tr, uk) with English placeholder translations - Update de.json with 117 missing translation keys including proper German translations - Update es, fr, it, nl, pl, pt, ru, zh translation files with missing keys using English fallbacks Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Add preferred_language column to user_profiles for i18n support.
|
|
|
|
Revision ID: 029_add_user_language_preference
|
|
Revises: 028_add_audit_logs
|
|
Create Date: 2026-03-09
|
|
"""
|
|
|
|
from typing import Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "029_add_user_language_preference"
|
|
down_revision: Union[str, None] = "028_add_audit_logs"
|
|
depends_on: Union[str, None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Add preferred_language column to user_profiles table."""
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
if "user_profiles" not in inspector.get_table_names():
|
|
return
|
|
existing_columns = {col["name"] for col in inspector.get_columns("user_profiles")}
|
|
if "preferred_language" not in existing_columns:
|
|
op.add_column(
|
|
"user_profiles",
|
|
sa.Column("preferred_language", sa.String(10), nullable=True, server_default=None),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Remove preferred_language column from user_profiles table."""
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
if "user_profiles" not in inspector.get_table_names():
|
|
return
|
|
existing_columns = {col["name"] for col in inspector.get_columns("user_profiles")}
|
|
if "preferred_language" in existing_columns:
|
|
op.drop_column("user_profiles", "preferred_language")
|