diff --git a/backend/alembic/versions/3fbb82ea683d_add_segment_translation_source.py b/backend/alembic/versions/3fbb82ea683d_add_segment_translation_source.py
new file mode 100644
index 0000000..24a63a1
--- /dev/null
+++ b/backend/alembic/versions/3fbb82ea683d_add_segment_translation_source.py
@@ -0,0 +1,46 @@
+"""Add segment translation source
+
+Revision ID: 3fbb82ea683d
+Revises: 32d5a77e6615
+Create Date: 2025-12-06 13:49:58.517637
+
+"""
+
+from typing import Sequence, Union
+
+from alembic import op
+import sqlalchemy as sa
+
+
+# pylint: disable=E1101
+
+# revision identifiers, used by Alembic.
+revision: str = "3fbb82ea683d"
+down_revision: Union[str, None] = "32d5a77e6615"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+segmentsource = sa.Enum(
+ "glossary",
+ "machine_translation",
+ "translation_memory",
+ "full_match",
+ name="recordsource",
+)
+
+
+def upgrade() -> None:
+ segmentsource.create(op.get_bind(), checkfirst=True)
+ op.add_column(
+ "document_record",
+ sa.Column(
+ "target_source",
+ segmentsource,
+ nullable=True,
+ ),
+ )
+
+
+def downgrade() -> None:
+ op.drop_column("document_record", "target_source")
+ segmentsource.drop(op.get_bind(), checkfirst=True)
diff --git a/backend/app/documents/models.py b/backend/app/documents/models.py
index b5547ba..4450ebd 100644
--- a/backend/app/documents/models.py
+++ b/backend/app/documents/models.py
@@ -97,6 +97,13 @@ class Document(Base):
)
+class RecordSource(Enum):
+ glossary = "glossary"
+ machine_translation = "mt"
+ translation_memory = "tm"
+ full_match = "fm" # for digits
+
+
class DocumentRecord(Base):
__tablename__ = "document_record"
@@ -105,6 +112,7 @@ class DocumentRecord(Base):
source: Mapped[str] = mapped_column()
target: Mapped[str] = mapped_column()
approved: Mapped[bool] = mapped_column(default=False)
+ target_source: Mapped[RecordSource] = mapped_column(nullable=True)
document: Mapped["Document"] = relationship(back_populates="records")
comments: Mapped[list["Comment"]] = relationship(
diff --git a/backend/app/documents/schema.py b/backend/app/documents/schema.py
index ff964c0..73eb8b9 100644
--- a/backend/app/documents/schema.py
+++ b/backend/app/documents/schema.py
@@ -2,10 +2,10 @@
from pydantic import BaseModel, Field
-from app.documents.models import TmMode
+from app.documents.models import RecordSource, TmMode
from app.glossary.schema import GlossaryResponse
from app.models import DocumentStatus, Identified, MachineTranslationSettings
-from app.translation_memory.schema import TranslationMemory, TranslationMemoryUsage
+from app.translation_memory.schema import TranslationMemory
class DocumentRecordFilter(BaseModel):
@@ -31,6 +31,7 @@ class DocumentRecord(Identified):
approved: bool
repetitions_count: int
has_comments: bool
+ translation_src: RecordSource | None
class DocumentRecordListResponse(BaseModel):
@@ -52,9 +53,7 @@ class DocumentRecordUpdate(BaseModel):
class DocumentProcessingSettings(BaseModel):
- substitute_numbers: bool
machine_translation_settings: Optional[MachineTranslationSettings]
- memory_usage: TranslationMemoryUsage
similarity_threshold: float = Field(default=1.0, ge=0.0, le=1.0)
diff --git a/backend/app/routers/document.py b/backend/app/routers/document.py
index e60f476..7745e98 100644
--- a/backend/app/routers/document.py
+++ b/backend/app/routers/document.py
@@ -118,7 +118,6 @@ def get_doc_records(
query = GenericDocsQuery(db)
total_records = query.get_document_records_count_filtered(doc, filters)
records = query.get_document_records_paged(doc, page, filters=filters)
-
record_list = [
doc_schema.DocumentRecord(
id=record.id,
@@ -127,6 +126,9 @@ def get_doc_records(
approved=record.approved,
repetitions_count=repetitions_count,
has_comments=has_comments,
+ translation_src=record.target_source.value
+ if record.target_source
+ else None,
)
for record, repetitions_count, has_comments in records
]
diff --git a/backend/app/translation_memory/schema.py b/backend/app/translation_memory/schema.py
index 3ba36b7..3262387 100644
--- a/backend/app/translation_memory/schema.py
+++ b/backend/app/translation_memory/schema.py
@@ -1,5 +1,3 @@
-from enum import Enum
-
from pydantic import BaseModel, Field
from app.base.schema import Identified
@@ -11,11 +9,6 @@ class MemorySubstitution(BaseModel):
similarity: float
-class TranslationMemoryUsage(Enum):
- NEWEST = "newest"
- OLDEST = "oldest"
-
-
class TranslationMemory(Identified):
name: str
created_by: int
diff --git a/backend/tests/fixtures/small.xliff b/backend/tests/fixtures/small.xliff
index 789c792..0269f36 100644
--- a/backend/tests/fixtures/small.xliff
+++ b/backend/tests/fixtures/small.xliff
@@ -23,6 +23,10 @@
123456789
+
+ Something else
+
+