S
S
sawa42016-06-23 09:56:44
Laravel
sawa4, 2016-06-23 09:56:44

How to use default localization in Laravel 5?

Good time!
How to use the standard methods for switching the language and fetching data from the database of the corresponding language?
Can someone describe in more detail, or point to an article where this is described, I could not find it?
For example, I have a table of articles with fields: articles(id, title_ru, title_en, content_ru, content_en), how can I pull out data when switching languages, and how is it written in routes?
like switching like this:

Route::get('{locale}', function ($locale) {
        $languages = ['ru','en'];
        if (in_array($locale, $languages)){
            Session::put('LANG', $locale);
            return Redirect::back();
        }
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Pochepko, 2016-06-23
@DJZT

You not that strategy of localization of a DB have chosen. I advise you to pay attention to these packages
dimsav/laravel-translatable
themsaid/laravel-multilingual
They use interesting approaches. You can use them, or write the necessary functions for the model yourself,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question