I
I
Igor Myasnikov2018-02-25 12:15:20
JavaScript
Igor Myasnikov, 2018-02-25 12:15:20

How to translate received data via Ajax?

Good day.
I am receiving data via Ajax in English , how can I display the data translated into another language ?
Do a normal switch

switch (key) {
    case first:
        name = 'первый'
        break;
    case second:
        name: = 'второй'
        break;
    default:
        break;
}

or
is there a better way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stepan Krapivin, 2018-02-25
@pilium

make a dictionary and take values ​​from it

var MESSAGES_RU = {
 'error': "ошибка",
 'done': "готово"
}

D
Dimonchik, 2018-02-25
@dimonchik2013

without highlighting the key from the translator through ajax in any way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question