Description

When set the current asset group language in a particular process, the asset refers to the "source asset" and output warning log.

LogPackageLocalizationCache: Warning: Skipping the cache update for %d pending package path(s) due to a cache request from a non-game thread. Some localized packages may be missed for this query.

The following code is a workaround for updating the cache of the asset group when changing the localized language.

 

Workaround

Adding update asset group culture cache when changing the culture.

\Engine\Source\Runtime\CoreUObject\Private\Internationalization\PackageLocalizationCache.cpp

void FPackageLocalizationCache::HandleCultureChanged()
{
    FScopeLock Lock(&LocalizedCachesCS);
 
    // Clear out all current caches and re-scan for the current culture
    CurrentCultureCache.Reset();
    AllCultureCaches.Empty();
 
    const FString CurrentCultureName = FInternationalization::Get().GetCurrentLanguage()->GetName();
    CurrentCultureCache = FindOrAddCacheForCulture_NoLock(CurrentCultureName);

    if (CurrentCultureCache.IsValid())
    {
        // We expect culture changes to happen on the game thread, so update the cache now while it is likely safe to do so
        // (ConditionalUpdateCache will internally check that this is currently the game thread before allowing the update)
        CurrentCultureCache->ConditionalUpdateCache();
    }

// <extension>
// Adding the Culture of AssetGroupLocalization
    FInternationalization::FCultureStateSnapshot CultureStateSnapshot;
    FInternationalization::Get().BackupCultureState(CultureStateSnapshot);
    TSet<FString> UniqueCultures;
    for (auto& AssetGroup : CultureStateSnapshot.AssetGroups)
    {
        if (!UniqueCultures.Contains(AssetGroup.Value))
        {
            if (TSharedPtr<FPackageLocalizationCultureCache> CultureCache = FindOrAddCacheForCulture_NoLock(AssetGroup.Value))
            {
                CultureCache->ConditionalUpdateCache();
            }
            UniqueCultures.Add(MoveTemp(AssetGroup.Value));
        }
    }
// </extension>

    ConditionalUpdatePackageNameToAssetGroupCache_NoLock();
}

Steps to Reproduce

Repro Steps

1.  Open attached project in editor.

2.  Packaging project with Win64.

3.  Launch package application and wait around 5 sec.

(automatically process in StartupMap)

SetCurrentLanguageAndLocale(ja) -> SetCurrentLanguageAndLocale(en) -> SetCurrentLanguageAndLocale(ja) -> SetCurrentAssetGroup(en) -> OpenLevel(LocalizationMap).

4. After moving level, press Langugae button.

Result:

 Play sound source asset.

Expected:

 Play sound localized asset (en).

 

The Asset Group (Audio) is set to "en".  So expect "en" in the Asset Group to be selected even if the current language is "ja".

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-103591 in the post.

0
Login to Vote

Fixed
ComponentUE - Editor - UI Systems - Localization
Affects Versions4.25
Target Fix5.0
Fix Commit14850903
Release Commit16054421
CreatedNov 22, 2020
ResolvedDec 3, 2020
UpdatedNov 30, 2022
View Jira Issue