kenepa / translation-manager

Manage your application's translations in Filament.
MIT License
86 stars 27 forks source link

How to actually use it .. ? #45

Closed Saad5400 closed 5 months ago

Saad5400 commented 5 months ago

I've followed the installation process. But how can I actually start adding translation keys/values and which function to use to get the translation depending on the locale and such.

Jehizkia commented 5 months ago

Now that you have everything installed, you should have a lang folder in your project with your translation keys. For example:

// lang/welcome.php
return [
    'message' => "Welcome to your dashboard"
];

Within the translation-manager interface, you can press the "synchronize" button. This will make all your translations from the lang folder appear in the table.

To translate a key, select the item you'd like to translate, and you'll be directed to the translation page. Add your translation for the desired language.

To use the translations in your code, you can use the following approaches:

__('welcome.message')
// or
trans('welcome.message')

When a user switches the language using the language switcher, the active session's language will be set, and the appropriate translation will be displayed to the user.

Saad5400 commented 5 months ago

Thanks, much appreciated