-
Notifications
You must be signed in to change notification settings - Fork 4
Working with Multiple Language Guide
Elevate the accessibility and user-friendliness of this Starter Project by embracing multiple languages. With the assistance of Filament Translations and the Laravel Lang package, this Starter Project offers comprehensive multilingual support.
As of now, this Starter Project provides support for two languages: Bangla and English. However, the flexibility is built in for you to add more languages based on your project's requirements.
To expand your project's language support, follow these steps:
-
Visit the Filament Translations Documentation:
Start by visiting the Filament Translations documentation to understand how to manage translations efficiently.
-
Leverage Laravel Lang:
The Laravel Lang package provides a wealth of language files for different languages. You can access and integrate these language files into your project.
-
Custom Translations:
If you require custom translations for specific project-related content, you can create your own translation files and integrate them with your project.
Adding a new language to your project is a breeze. Execute the following command to publish a new language:
php artisan lang:add es
It will be installed in lang\es
folder
Inside your language folder, you can add custom translations to tailor your project to specific language requirements. For example, check out this sample Bangla translation in resources.php
:
<?php
declare(strict_types=1);
return [
'role' => 'রোল',
'role.plural' => 'রোলগুলো',
'permission' => 'পার্মিশন',
'permission.plural' => 'পার্মিশনগুলো',
'user' => 'ব্যবহারকারী',
'user.plural' => 'ব্যবহারকারীরা',
];
To implement custom translations in Filament, you can set the Model label and plural Label in a resource, and the rest of the translation will be handled by Filament translations. Here's an example:
public static function getModelLabel(): string
{
return __('resources.user');
}
public static function getPluralLabel(): ?string
{
return __('resources.user.plural');
}