From 315897aa9ca8acb1c5dc88d277c8f796383a616b Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Fri, 21 Apr 2017 15:50:58 +0300 Subject: [PATCH] When the language of the user is equal to one of the languages of the MWM only single name scheme is used. --- indexer/feature_utils.cpp | 5 +++++ indexer/indexer_tests/feature_names_test.cpp | 21 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 4e249c83ec..64b7d8779c 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -231,6 +231,11 @@ void GetPreferredNames(RegionData const & regionData, StringUtf8Multilang const if (src.IsEmpty()) return; + // When the language of the user is equal to one of the languages of the MWM + // only single name scheme is used. + if (regionData.HasLanguage(deviceLang)) + return GetReadableName(regionData, src, deviceLang, allowTranslit, primary); + vector const primaryCodes = {deviceLang, StrUtf8::kInternationalCode, StrUtf8::kEnglishCode}; diff --git a/indexer/indexer_tests/feature_names_test.cpp b/indexer/indexer_tests/feature_names_test.cpp index 19b53f9a04..282513d8c5 100644 --- a/indexer/indexer_tests/feature_names_test.cpp +++ b/indexer/indexer_tests/feature_names_test.cpp @@ -169,6 +169,27 @@ UNIT_TEST(GetPrefferedNames) } } +UNIT_TEST(GetPrefferedNamesLocal) +{ + feature::RegionData regionData; + regionData.SetLanguages({"kk", "ru"}); + + int8_t deviceLang = StrUtf8::GetLangIndex("ru"); + string primary, secondary; + bool const allowTranslit = true; + + { + StrUtf8 src; + src.AddString("default", "default name"); + src.AddString("en", "en name"); + + feature::GetPreferredNames(regionData, src, deviceLang, allowTranslit, primary, secondary); + + TEST_EQUAL(primary, "default name", ()); + TEST_EQUAL(secondary, "", ()); + } +} + UNIT_TEST(GetReadableName) { feature::RegionData regionData;