How to translate Resource model name?

My model is called Form. But the application is in Spanish. all seems well translated except for the resources model names. Form should be Formulario. Is there any way to translate it? now i see it all like this: left admin panel sidebar: Forms -> should be Formularios "Crear form" -> should be "Crear formulario" etc im trying to find how to do it in the docs, but so far havent found it
5 Replies
ericmp #2
ericmp #2OP12mo ago
brigado but one think i dont undestand, what this means?
public static function getModelLabel(): string
{
return __('filament/resources/form.label');
}
public static function getModelLabel(): string
{
return __('filament/resources/form.label');
}
im suposed to have a folder called form inside app/Filament/Resources and a file called label in my project where inside i define the translation or how it works?
LeandroFerreira
LeandroFerreira12mo ago
you could create in the lang folder https://laravel.com/docs/10.x/localization#using-translation-strings-as-keys lang/es.json
{
"Custom": "xxx"
}
{
"Custom": "xxx"
}
__('Custom')
__('Custom')
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
ericmp #2
ericmp #2OP12mo ago
ah okay, so using just laravel normal translations u could just say that haha, i know how they work but thanks, appreciate it i got confused cuz of this __('filament/resources/form.label') so just __('form')
GuyVerville
GuyVerville9mo ago
While I am able to translate the model name in my language, Filament capitalizes every word of the model (English convention, in French, we don't). So I have to bypass the getTitleCaseModelLabel and getTitleCasePluralModelLabel() using for example a Trait. Is there a way to tell Filament just not to capitalize? (Copilot suggests to create a BaseResource that extends Resource and place the modified functions). Then, every resource would extend the BaseResource instead of Resource.
Want results from more Discord servers?
Add your server