Makes the fields a model's #[Translatable] names carry further languages. The attribute
declares, the trait acts:
#[Translatable(['title', 'description'])]
final class Item extends Model
{
use HasTranslations;
}
The base-language value stays in the column; the further languages live in sdk_translations. Reading: every
query of the model delivers those fields in the request's language — the further-language text, else the column's
base value, never English — and $filter, $orderby and $search run on that text: the column itself, no Common.Text
sibling. Editing binds the translations navigation, which lists
every language including the base — not the field, which arrives already translated. Writing:
{@see setTranslations()}, from the owning module's action, in its transaction. The translations go with the
row when it is deleted.
Provisional until the first real multilingual project in Switzerland.
| Methods | ||
|---|---|---|
public
static
|
bootHasTranslations(): void
|
# |
public
|
translation(string $property, string $language): ?string
|
# |
public
|
translated(string $property, ?string $language = null): ?string
|
# |
public
|
setTranslations(array<string, array<string, string|null>> $byLanguage): void
|
# |
public
|
setTranslation(string $property, string $language, string $text): void
|
# |
public
|
translatableFields(): list<string>
|
# |