D
D
Dmitry2016-10-28 16:18:43
PHP
Dmitry, 2016-10-28 16:18:43

What are the ways to change the language on the site without reloading the page?

Let's say we also have rulanguages en​​for the site. The default enis , you need to change the page language to ru. How to implement this correctly? The only thing that comes to my mind is clearing the block and then filling it with text from the array in json. And then, I still think that this is literally an idiotic way.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iBird Rose, 2016-10-28
@letehaha

well, you can store static text that will always be the same in the same element in the data attribute, and then replace it everywhere with one line through js. and the content - in any case, through ajax you will have to load
like this: https://jsfiddle.net/iBird/zLezzktL/

A
Anton, 2016-10-28
@SPAHI4

For this, it is easiest to use js frameworks. For each framework there is a ready-made tool for internationalization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question