Display all translations

Howdy, is there a way to display all translations used by a model using the Spatie Translatable plugin? Like, if I have a name column, and it gets translated to 4 languages. How would I go about displaying all 4 languages at the same time, rather than having to edit, save, swap language, edit, save, etc.?
Solution:
Turns out https://filamentphp.com/plugins/mvenghaus-translatable-inline exists, and is perfect for my usecase.
Filament
Translatable Inline by Marcus Venghaus - Filament
Addon for Spatie Translatable Plugin to edit translations directly below the field
Jump to solution
2 Replies
Sauravisus
SauravisusOP11mo ago
Would I have to do a loop based on the languages used, to output the amount of TextInputs for each thing? So far I've got this:
foreach($locales as $locale){
$schema[] = TextInput::make("name")
->label(__('general.Name') . " - " . $locale)
->formatStateUsing(function ($record, $state) use ($locale) {
return $record->getTranslation('name', $locale);
})
->required();
$schema[] = TextInput::make("synonyms")
->label(__('general.Synonyms') . " - " . $locale)
->formatStateUsing(function ($record, $state) use ($locale) {
return $record->getTranslation('synonyms', $locale);
})
->required();
}
foreach($locales as $locale){
$schema[] = TextInput::make("name")
->label(__('general.Name') . " - " . $locale)
->formatStateUsing(function ($record, $state) use ($locale) {
return $record->getTranslation('name', $locale);
})
->required();
$schema[] = TextInput::make("synonyms")
->label(__('general.Synonyms') . " - " . $locale)
->formatStateUsing(function ($record, $state) use ($locale) {
return $record->getTranslation('synonyms', $locale);
})
->required();
}
And while it does make the fields for each of my locales, for some reason the translation obtained is the one for my applanguage, not the locale we're currently on in the loop. I'm quite confused as to why that'd be the case.
Solution
Sauravisus
Sauravisus11mo ago
Turns out https://filamentphp.com/plugins/mvenghaus-translatable-inline exists, and is perfect for my usecase.
Filament
Translatable Inline by Marcus Venghaus - Filament
Addon for Spatie Translatable Plugin to edit translations directly below the field
Want results from more Discord servers?
Add your server