fix: show target-language-specific translations in preview + rename migration
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Two issues found in screenshot review: 1. Glossary preview always showed English 'target' field (foie → liver) instead of the language-specific translation. Now looks up term.translations[targetLang] first, falls back to term.target. When target is Persian, preview shows 'foie → کبد' (Persian). 2. Previous migration b7c8d9e0f1a2 was already applied on server before the rename was added. New migration c8d9e0f1a2b3 handles the rename separately: glossaries with target_language='multi' get their name changed from 'Anglais' to 'Multilingue'. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Rename multilingual glossaries from 'Anglais' to 'Multilingue'
|
||||
|
||||
Revision ID: c8d9e0f1a2b3
|
||||
Revises: b7c8d9e0f1a2
|
||||
Create Date: 2026-05-31
|
||||
|
||||
Previous migration b7c8d9e0f1a2 set target_language='multi' but the rename
|
||||
part was added after the migration was already applied on the server.
|
||||
This migration handles the rename separately.
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers
|
||||
revision = "c8d9e0f1a2b3"
|
||||
down_revision = "b7c8d9e0f1a2"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Rename glossaries that are multilingual but still have "Anglais" in name
|
||||
op.execute("""
|
||||
UPDATE glossaries
|
||||
SET name = REPLACE(name, 'Anglais', 'Multilingue')
|
||||
WHERE target_language = 'multi'
|
||||
AND name LIKE '%%Anglais%%'
|
||||
""")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("""
|
||||
UPDATE glossaries
|
||||
SET name = REPLACE(name, 'Multilingue', 'Anglais')
|
||||
WHERE target_language = 'multi'
|
||||
AND name LIKE '%%Multilingue%%'
|
||||
""")
|
||||
Reference in New Issue
Block a user