From e1b7de9f0854ccf9b07fb2a7fc1b16d0c78f2a91 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Thu, 11 May 2023 09:39:26 +0200 Subject: [PATCH] [ios][tts] Fixed non-working pt-BR and es-MX TTS selection in OM Signed-off-by: Alexander Borsuk --- iphone/Maps/Classes/LocaleTranslator.mm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iphone/Maps/Classes/LocaleTranslator.mm b/iphone/Maps/Classes/LocaleTranslator.mm index 1e774bc76a..d46a786c14 100644 --- a/iphone/Maps/Classes/LocaleTranslator.mm +++ b/iphone/Maps/Classes/LocaleTranslator.mm @@ -2,22 +2,22 @@ namespace locale_translator { - -std::string bcp47ToTwineLanguage(NSString const * bcp47LangName) +std::string bcp47ToTwineLanguage(NSString const * bcp47) { - if (bcp47LangName == nil || [bcp47LangName length] < 2) + if (bcp47 == nil || bcp47.length < 2) return {}; - if ([bcp47LangName isEqualToString:@"zh-CN"] || [bcp47LangName isEqualToString:@"zh-CHS"] - || [bcp47LangName isEqualToString:@"zh-SG"]) - { - return "zh-Hans"; // Chinese simplified - } + // Update this array if new bcp47 languages are added into data/strings/sound.txt + if ([@[@"pt-BR", @"es-MX"] containsObject:bcp47]) + return bcp47.UTF8String; // Unchanged original bcp47 string - if ([bcp47LangName hasPrefix:@"zh"]) + if ([@[@"zh-CN", @"zh-CHS", @"zh-SG"] containsObject:bcp47]) + return "zh-Hans"; // Chinese simplified + + if ([bcp47 hasPrefix:@"zh"]) return "zh-Hant"; // Chinese traditional // Taking two first symbols of a language name. For example ru-RU -> ru - return [bcp47LangName substringToIndex:2].UTF8String; + return [bcp47 substringToIndex:2].UTF8String; } } // namespace locale_translator