Skip to content

Working with Multiple Language Guide

Azizul Hakim edited this page Oct 13, 2023 · 7 revisions

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.

Supported Languages

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.

Getting Started

To expand your project's language support, follow these steps:

  1. Visit the Filament Translations Documentation:

    Start by visiting the Filament Translations documentation to understand how to manage translations efficiently.

  2. 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.

  3. 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.

Publishing a new language

you can add a new language by following this command

php artisan lang:add es

Project Directory Structure

Inside your language folder you can add your custom translations for example check this bangla translation code

<?php

declare(strict_types=1);

return [
    'role'   => 'রোল',
    'role.plural' => 'রোলগুলো',
    'permission' => 'পার্মিশন',
    'permission.plural' => 'পার্মিশনগুলো',
    'user' => 'ব্যবহারকারী',
    'user.plural' => 'ব্যবহারকারীরা',
];

Using Custom Translation in Filament

You can set the Model label and plural Label in a resource and rest of the translation will be done by Filament translations

   public static function getModelLabel(): string
    {
        return __('resources.user');
    }
    public static function getPluralLabel(): ?string
    {
        return __('resources.user.plural');
    }
Clone this wiki locally