TenantTranslation
Tenant-specific translation overrides.
Allows tenants to customize translations to match their terminology,
industry, or brand voice. Overrides system translations when present.
Attributes:
tenant_id: Tenant identifier (from TenantContext)
source_text: Original text to translate (1-1000 characters)
translated_text: Translated text in target locale (1-1000 characters)
locale: Locale code (e.g., "en", "hi", "ta", "es_MX")
context: Optional context for disambiguation (e.g., "button", "field_label")
Constraints:
- Unique combination of (tenant_id, source_text, locale, context)
- locale must match pattern: 2 lowercase letters, optionally followed by
underscore and 2 uppercase letters (e.g., "en", "en_US", "pt_BR")
Example:
# Healthcare tenant uses "Patient" instead of "Customer"
TenantTranslation(
tenant_id="healthcare-corp",
source_text="Customer",
translated_text="Patient",
locale="en",
context="field_label"
)
# Retail tenant uses "Client" in French
TenantTranslation(
tenant_id="retail-corp",
source_text="Customer",
translated_text="Client",
locale="fr",
context="field_label"
)
Source: tenant_translation.py
Fields
| Field | Type | Required | Description | Validators |
|---|---|---|---|---|
| tenant_id | str | Tenant identifier from TenantContext | minLen: 1, maxLen: 100 | |
| source_text | str | Original text to translate | minLen: 1, maxLen: 1000 | |
| translated_text | str | Translated text in target locale | minLen: 1, maxLen: 1000 | |
| locale | str | Locale code (e.g., 'en', 'hi', 'ta', 'es_MX') | minLen: 2, maxLen: 10, pattern: ^[a-z]{2}(_[A-Z]{2})?$ | |
| context | str | None | Optional context for disambiguation (e.g., 'button', 'field_label') |
Configuration
| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Controller hooks are implemented in *_controller.py files.
Available lifecycle hooks:
validate()- Called before save, raise exceptions for validation errorsbefore_insert()- Called before inserting a new documentafter_insert()- Called after successfully insertingbefore_save()- Called before saving (insert or update)after_save()- Called after savingbefore_delete()- Called before deletingafter_delete()- Called after deleting