Hi there, I am writing an editor tool that will read all localised strings and compare their length in each languange, hilighting any localised strings that are significantly longer than the default language. I’m hoping that this will help QA to spot text bleeding outside of the UI components.
Unfortunately I am really struggling to get to the localised values and would appreciate any pointers. Here is my latest attempt which is delivering all of the localised strings as the same as the default language:
TextBleedStringTableEntries.Empty();
FStringTableRegistry::Get().EnumerateStringTables([this]
(const FName & TableName, const FStringTableConstRef & StringTable)
{
StringTable->EnumerateSourceStrings([this, TableName]
(const FString& Key, const FString& Display)
{
TextBleedStringTableEntries.Push({TableName, Key, Display});
return true;
});
return true;
});
const FTextLocalizationManager& Localization = FTextLocalizationManager::Get();
const TArray<FString> Cultures = Localization.GetLocalizedCultureNames(ELocalizationLoadFlags::Game);
FInternationalization& Internationalization = FInternationalization::Get();
const FString& DefaultCulture = Internationalization.GetDefaultCulture()->GetName();
for (const FString& Culture : Cultures)
{
if (DefaultCulture != Culture)
{
if (Internationalization.SetCurrentCulture(Culture))
{
FTextLocalizationManager::Get().RefreshResources();
for (FTextBleedStringTableData& Localised : TextBleedStringTableEntries)
{
const FText& Display = FText::FromStringTable(Localised.Table, Localised.Key);
Localised.Localisations.Add(Culture, Display.ToString());
}
}
}
}
Internationalization.SetCurrentLanguage(DefaultCulture);