Skip to main content

Multi-language: System Texts, Labels, Menus

Premium
4:58

Text Version of the Lesson

If you work with multi-language projects in Filament, there's not much you need to learn, as Filament primarily relies on Laravel Localization features. But I will briefly demonstrate to you how it works.


Filament "System" Translations

Filament has many components translated into many languages: buttons, labels, menu items, etc.

So, you can just change the system locale in Laravel, and Filament will automatically apply the new translated texts.

config/app.php

'locale' => 'en',
'locale' => 'lt',

Here's how the Filament dashboard will look now, with some system words translated into my Lithuanian language:

But, of course, the rest is up to you to translate all the things manually.

If you want to edit those system translations, you need to publish them, it's part of the installation process, but you may also do it later.

php artisan vendor:publish --tag=filament-panels-translations

Then you will have a lot of language files in /lang/vendor/filament-panels:

Inside each language, you will see a structure of files. They are pretty self-explanatory in their purpose. Each file is a PHP array:

So you can try to edit any value, and it will be shown on...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

HA
Horváth András ✓ Link copied!

Hello.

Product

How can we translate the resource name "Product" not just in the menu, but on the resource section of the page, for example in the bold text "Sukurti Product"?

Thank you

PK
Povilas Korop ✓ Link copied!

There are methods getModelLabel() and getPluralModelLabel()

Z
Zhtekdev ✓ Link copied!

How to translate the model name, when I click create product button, it shows the second word "product" still English, but the first word "Create" already be translated.

Z
Zhtekdev ✓ Link copied!

Just found out the answer: public static function getModelLabel(): string { return __('Product'); }

S
steff700 ✓ Link copied!

Hm, i didnt catch this. Resourcefile XY: Tables\Columns\TextColumn::make('description') ->label(__('Description')), de.json: { "Description": "Beschreibung", } This works fine in table view. If i click on edit/create etc, the label and translation is away. The field (label) description => Description Do you have an example?

S
steff700 ✓ Link copied!

I got it. You also have to code the translation method in the resource in return form/schema, not just in return table/column.

MN
Md Nishat Miah ✓ Link copied!

How to use this in SAAS project? like, if I have 2 tenants one from France and another from Italy then store translations in file doesn't work.

M
Modestas ✓ Link copied!

Why wouldn't it work? You just have to add the language switcher to the UI, but other than that - it has to work. Especially since the way you store translations has nothing to do with SAAS projects

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.