match any regional string for a generic language request after exhausting the pool for exact matches in polyglot FText JSON

#JIRA: FORT-158282

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: david.nikdel
#ROBOMERGE-SOURCE: CL 5420579 via CL 5420589 via CL 5427948 via CL 5428073
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 5431681 by david nikdel in Dev-Networking branch]
This commit is contained in:
david nikdel
2019-03-18 13:10:41 -04:00
parent c35bea21f0
commit 31c509656d

View File

@@ -331,6 +331,28 @@ bool FJsonObjectConverter::GetTextFromObject(const TSharedRef<FJsonObject>& Obj,
}
}
// try again but only search on the locale region (in the localized data). This is a common omission (i.e. en-US source text should be used if no en is defined)
for (const FString& LocaleToMatch : CultureList)
{
int32 SeparatorPos;
// only consider base language entries in culture chain (i.e. "en")
if (!LocaleToMatch.FindChar('-', SeparatorPos))
{
for (const auto& Pair : Obj->Values)
{
// only consider coupled entries now (base ones would have been matched on first path) (i.e. "en-US")
if (Pair.Key.FindChar('-', SeparatorPos))
{
if (Pair.Key.StartsWith(LocaleToMatch))
{
TextOut = FText::FromString(Pair.Value->AsString());
return true;
}
}
}
}
}
// no luck, is this possibly an unrelated json object?
return false;
}