F
Filament16mo ago
ivanv

how can i change these texts to spanish?

All my environment is in english (database and code) but I am in a country where people’s native language is spanish, so I need to change some text likes these that are marked, that are basically created by make:filament-resource
Solution:
For the model name you can do something like this: ```php public static function getModelLabel(): string { return __('Product Category');...
Jump to solution
4 Replies
awcodes
awcodes16mo ago
First look into how translations work in laravel. Then you need to override the appropriate methods on the filament resources / pages to return your translations.
Solution
ILPAV
ILPAV16mo ago
For the model name you can do something like this:
public static function getModelLabel(): string
{
return __('Product Category');
}

public static function getPluralModelLabel(): string
{
return __('Product Categories');
}
public static function getModelLabel(): string
{
return __('Product Category');
}

public static function getPluralModelLabel(): string
{
return __('Product Categories');
}
and insert the two strings inside the lang/es.json file
ILPAV
ILPAV16mo ago
For the rest of the missing translation I suggest taking them from this repository: https://github.com/Laravel-Lang/lang
GitHub
GitHub - Laravel-Lang/lang: List of 78 languages for Laravel Framew...
List of 78 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI. - GitHub - Laravel-Lang/lang: List of 78...
ivanv
ivanvOP16mo ago
Thank you!! I was at documentation and I was using $label protected static, but that way that you suggested me is better because I can specify when use plural or singular label.
Want results from more Discord servers?
Add your server