E
E
Eugene2022-01-21 11:27:10
Laravel
Eugene, 2022-01-21 11:27:10

How to properly localize an application in Laravel?

I got acquainted with the docks, but the general approach is a little incomprehensible.
If I have a project (CRM system) in several languages. How to make a global language switch for an application?

App::setLocale($locale); - sets the language for the specific request where this string is specified. To store the installed language by the user in the session, as I think it's wrong.

Tell me who and how localized applications?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2022-01-21
@atachrus

I "store" the language in the URL
/about - in English
/ru/about - in Russian
/ar/about - in Arabic
, etc.
When I first visit by IP, I recognize the country and redirect the user to the desired localization.
You can determine for the first time by the Accept language header (I like it better) I
use this package https://github.com/mcamara/laravel-localization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question