feat: multiple translations with context, improved task examples
- Add WordTranslation model for storing multiple translations per word - AI generates translations with example sentences and their translations - Show example usage after answering tasks (learning + interface language) - Save translations to word_translations table when adding words from tasks - Improve word exclusion in new_words mode (stronger prompt + client filtering) - Add migration for word_translations table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
37
migrations/versions/20251206_add_word_translations.py
Normal file
37
migrations/versions/20251206_add_word_translations.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Add word_translations table for multiple translations with context
|
||||
|
||||
Revision ID: 20251206_word_translations
|
||||
Revises: 20251205_wordsource_ai_task
|
||||
Create Date: 2025-12-06
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '20251206_word_translations'
|
||||
down_revision: Union[str, None] = '20251205_wordsource_ai_task'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'word_translations',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('vocabulary_id', sa.Integer(), nullable=False),
|
||||
sa.Column('translation', sa.String(255), nullable=False),
|
||||
sa.Column('context', sa.String(500), nullable=True),
|
||||
sa.Column('context_translation', sa.String(500), nullable=True),
|
||||
sa.Column('is_primary', sa.Boolean(), nullable=False, server_default='false'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.func.now()),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('ix_word_translations_vocabulary_id', 'word_translations', ['vocabulary_id'])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index('ix_word_translations_vocabulary_id', table_name='word_translations')
|
||||
op.drop_table('word_translations')
|
||||
Reference in New Issue
Block a user