[ios] Pass correct locale to GetHotelInfo.

This commit is contained in:
VladiMihaylenko 2017-03-09 12:15:14 +03:00 committed by Sergey Yershov
parent 0c5653407a
commit 1866260e58
3 changed files with 16 additions and 1 deletions

View file

@ -11,6 +11,7 @@
@property(nonatomic, readonly) NSString * buildNumber;
@property(nonatomic, readonly) NSUUID * advertisingId;
@property(nonatomic, readonly) NSString * languageId;
@property(nonatomic, readonly) NSString * twoLetterLanguageId;
@property(nonatomic, readonly) NSDate * buildDate;
@property(nonatomic, readonly) NSString * deviceName;
@property(nonatomic, readonly) BOOL isMetalDriver;

View file

@ -198,6 +198,19 @@ NSDictionary * const kDeviceNamesWithMetalDriver = @{
return languages.count == 0 ? nil : languages[0];
}
- (NSString *)twoLetterLanguageId
{
NSString * languageId = self.languageId;
auto constexpr maxCodeLength = 2UL;
auto const length = languageId.length;
if (length > maxCodeLength)
languageId = [languageId substringToIndex:maxCodeLength];
else if (length < maxCodeLength)
languageId = @"en";
return languageId;
}
- (NSDate *)buildDate
{
if (!_buildDate)

View file

@ -171,7 +171,8 @@ using namespace place_page;
if (auto const api = GetFramework().GetBookingApi(canUseNetwork))
{
string const hotelId = self.sponsoredId.UTF8String;
api->GetHotelInfo(hotelId, [[AppInfo sharedInfo] languageId].UTF8String, [hotelId, self](booking::HotelInfo const & hotelInfo)
api->GetHotelInfo(hotelId, [[AppInfo sharedInfo] twoLetterLanguageId].UTF8String,
[hotelId, self](booking::HotelInfo const & hotelInfo)
{
if (hotelId != hotelInfo.m_hotelId)
return;