E
E
Evgeny Perin2016-04-06 19:05:20
Laravel
Evgeny Perin, 2016-04-06 19:05:20

Why user data in English, socialite + vk + laravel?

I made a way to register on the site through Vkontakte, I used socialite + vk provider + laravel. After registration, data about the user is returned, but the data is in English, although the site is in Russian. I checked on three accounts, from different locations in Russia, the data is still returned in English.
How can this be fixed? The vendor has the following request:

protected function getUserByToken($token)
    {
        $response = $this->getHttpClient()->get(
            'https://api.vk.com/method/users.get?user_ids='.$token['user_id'].'&fields=uid,first_name,last_name,screen_name,photo'
        );
.......

The vk api has the ability to set the language using the lang=ru parameter, but it is wrong to write this in the vendor code. Actually the question is why the data comes in English and how to change it without changing the vendor code? Where can I override this method?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Evgeny Perin, 2016-04-07
@seoperin

I thought about this option. When socialite receives user data, do not write it down, but make another call to vk api using the user ID, and pull out all the necessary information already in Russian, passing the lang=ru parameter, you will get one request to api more, but the result is necessary. The repeated appeal will be only at registration and not at each entrance to the site, so I think there will be nothing terrible from this. For now I will do so, but probably the problem is in the location of the server.

S
Stanislav Pochepko, 2016-04-06
@DJZT

Try setting the application language variable in config/app.php to en

V
vadym26, 2016-10-14
@vadym26

Set the variable VKONTAKTE_LANG with the value ru in the env file.
VKONTAKTE_LANG=ru

D
dimitr0s, 2021-04-26
@dimitr0s

/config/services.php
Where you have settings for VK, add 'lang'=>'ru', you should get something like:
'vkontakte' => [
'client_id' => env('VKONTAKTE_CLIENT_ID'),
'client_secret' => env('VKONTAKTE_CLIENT_SECRET'),
'redirect' => env('VKONTAKTE_REDIRECT_URI') ,
'lang' => 'en'
],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question