A
A
Askfortrue2019-01-30 10:58:26
1C-Bitrix
Askfortrue, 2019-01-30 10:58:26

How to get location output in Cyrillic (ru) and Latin (en) in Bitrix?

Hello!
Dear experts, tell me how can I get the output of locations from the location module 2.0 in Russian and in en, with transcription as indicated in locations (en)? Through the output agent the complete nonsense turns out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kudis, 2019-01-31
@kudis

If you have not yet exhausted the limit of free requests or paid for a paid package to a geo data provider from those that are in Bitrix out of the box (below we use the free part of Sypex), then the request:

use \Bitrix\Main\Service\GeoIp;
$result = GeoIp\Manager::getDataResult('178.219.187.10', 'en');
if ($result->isSuccess()) {
    $obGeoData = $result->getGeoData();
    print_r($obGeoData);
}

will give you this answer:
[ip] => 178.219.187.10
[lang] => en
[countryName] => Russia
[regionName] => Moskva
[subRegionName] => 
[cityName] => Moscow
[countryCode] => RU
[regionCode] => RU-MOW
[zipCode] => 
[latitude] => 55.75222
[longitude] => 37.61556
[timezone] => Europe/Moscow
[asn] => 
[ispName] => 
[organizationName] => 
[handlerClass] => Bitrix\Main\Service\GeoIp\SypexGeo

replacing 'en' with 'ru' in the request, you get:
[ip] => 178.219.187.10
[lang] => ru
[countryName] => Россия
[regionName] => Москва
[subRegionName] => 
[cityName] => Москва
[countryCode] => RU
[regionCode] => RU-MOW
[zipCode] => 
[latitude] => 55.75222
[longitude] => 37.61556
[timezone] => Europe/Moscow
[asn] => 
[ispName] => 
[organizationName] => 
[handlerClass] => Bitrix\Main\Service\GeoIp\SypexGeo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question