Good day to all. Please tell me faced with such a task. There is an online store written in Laravel 5.4 Online store in Russian, the task is to add English.

As I see the solution to this problem:

  1. Add a table with localization to the database. (En, ru)

  2. In all existing tables add external id to ru

  3. Create tables and fill them with English content and hang on them external id on en

  4. Check depending on what prefix came and pull information from the right tables.

This is a very time-consuming solution that requires changing the database structure. Also in the admin add fields under the English content. And if, for example, tomorrow they also say that German will be added, then all this will need to be repeated again, and so on.

Perhaps there is some simpler way of this implementation on Laravel 5.4?

  • Add language prefixes for text fields to each table with content, for example, there is a Pages table that has Title , Description fields, make Title_ru , Title_en , etc. of them. Then, when you determine the current language, make queries of the form SELECT Title_{$currentLang} AS Title - DaemonHK
  • Good morning. Here again, you need to drastically change the structure of the database, namely to add fields to already existing tables with a bunch of data. I would like to do something like not to touch the existing database structure. - Nick

1 answer 1

In the database, instead of the displayed text, store the key by which you will receive the desired text in the desired location. And use the built-in framework solution: localization .