F
F
freeman02042016-11-22 19:57:27
PHP
freeman0204, 2016-11-22 19:57:27

What is the easiest way to make a bilingual site?

Here's what I googled. I saw such options, there is a site site.com/en or site.com/ru i.e. I chose a language, for example Russian, and if I go to the page about us, it will be something like that site.com/ru/o_nas; if in English, then site.com/en/o_nas i.e. there is a page en and ru and it works through them. I need that when I click on en|ru, respectively, the site will be completely twisted and which page I would not go to, it would be in the selected language. At the expense of cookies and sessions, they are not important now, the main thing is that until the browser is closed, the language remains selected until the user switches to another one. OOP and the like are not needed, the simplest is procedural. Everything is taken from the database, as I understand it, if there are 2 languages, then you need to create 2 tables o_nas_ru and o_nas_en and, provided that you write in the right one. But in practice it doesn't.
I also saw this index.php? lang-en or index.php? lang-ru, these get parameters are added when you click on the language selection and let's say the main one has been translated, although I haven't succeeded yet. but if you go to site.com/o_nas then these get parameters disappear.
What I coded:
block I language switching.

<div class="tag">Language:<a href="index.php?lang-en">English</a>|<a href="index.php?lang=ru">Русский</div>

How to do what I described above, and so that the desired text from the admin panel is written to the desired table (in the admin panel there will be two fields at once, for example, for Russian and English text and different tables in the database) and displayed depending on what is selected on the site ru or en? It is possible a small example for understanding of an essence.
And how to make it so that it would be Russian according to the standard, i.e. so that not just index.php is loaded into index.php.ru or index.php?lang.ru which is correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
metallix, 2016-11-22
@freeman0204

As an option, in the tables with the content, you can add the language field, where the id or ISO code of the language will be stored accordingly, according to which the necessary records will be loaded.
those.
will load posts with language == 'en'.
Generally speaking, the principle is

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question