A
A
Alexander Litvinov2014-04-17 17:14:06
Yii
Alexander Litvinov, 2014-04-17 17:14:06

How to connect ContentNegotiator?

I want to connect the ContentNegotiator to determine the language in the restful api.
My config

'bootstrap' => [ 
        [
            'class' => 'yii\filters\ContentNegotiator',
            'formats' => [
                'application/json' => Response::FORMAT_JSON,
                'application/xml' => Response::FORMAT_XML,
            ],

            'languages' => [
                'ru',
                'en',
            ],

        ],
    ],

In the header I send I Accept-Language: ru
check through
Yii::$app->language;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Litvinov, 2014-04-21
@Sander_Li

Solved https://github.com/yiisoft/yii2/issues/3165

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question