M
M
Maxim Grechushnikov2016-03-17 20:33:10
Yii
Maxim Grechushnikov, 2016-03-17 20:33:10

Yii2: How to translate REST response?

I have 2 tables.
Clubs and
cities
When I create a club, a list of cities is requested through rest.
Question.
1. how to make a translation of what the rest gives?
2. how to make a search in the rest, taking into account the fact that they enter something not on the sourceLanguage?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eliseev, 2016-03-17
@maxyc_webber

yii\rest\Controller has a ContentNegotiator filter, which also accepts the language in Yii::$app->language. Configure supported languages ​​via the container:

Yii::$container->set('yii\filters\ContentNegotiator', [
    'languages' => ['en', 'ru'],
]);

And send requests with the language:
The parameter name _lang can also be overridden.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question