CollectionFilters

CollectionFilters

#Overview

name: CollectionFilters

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CollectionFilters is to specify which collections of assets should be included when gathering text for localization in Unreal Engine 5. It is primarily used in the localization and text gathering systems.

This setting variable is relied upon by the Localization module and the UnrealEd module, specifically in the context of gathering text from assets for localization purposes. It is used in the GatherTextFromAssetsCommandlet, which is responsible for collecting localizable text from various assets in the engine.

The value of this variable is typically set in configuration files or scripts used for localization. It can be populated from a configuration section using the GetStringArrayFromConfig function, as seen in the ConfigureFromScript method of the GatherTextFromAssetsCommandlet.

CollectionFilters interacts with other variables and systems, such as:

Developers should be aware of the following when using this variable:

  1. The collections specified must exist in the project, or an error will be logged.
  2. It works in conjunction with other filtering mechanisms, so its effect may be influenced by other settings.
  3. The variable expects collection names as strings.

Best practices when using this variable include:

  1. Ensure that the specified collections exist in the project before running the text gathering process.
  2. Use it in combination with other filters to precisely target the desired assets for localization.
  3. Keep the list of collections up-to-date as the project evolves to maintain accurate localization gathering.
  4. Document the collections used for localization to help team members understand which assets are being included in the process.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/Localization/Game_Gather.ini:53, section: [GatherTextStep1]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/LocalizationConfigurationScript.cpp:386

Scope (from outer to inner):

file
namespace    LocalizationConfigurationScript
function     FLocalizationConfigurationScript GenerateGatherTextConfigFile

Source code excerpt:

			for (const auto& CollectionName : Target->Settings.GatherFromPackages.Collections)
			{
				ConfigSection.Add( TEXT("CollectionFilters"), CollectionName.ToString() );
			}

			// Class filters
			for (const FSoftClassPath& ExcludeClass : Target->Settings.GatherFromPackages.ExcludeClasses)
			{
				if (ExcludeClass.IsValid())

#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/UserGeneratedContentLocalization.cpp:324

Scope (from outer to inner):

file
namespace    UserGeneratedContentLocalization
function     bool ExportLocalization

Source code excerpt:

				if (const FString* CollectionFilter = ExportOptions.PluginNameToCollectionNameFilter.Find(Plugin->GetName()))
				{
					ConfigSection.Add(TEXT("CollectionFilters"), *CollectionFilter);
				}
				
				GatherConfig.AddGatherTextStep(GatherStepIndex++, MoveTemp(ConfigSection));
			}

			// Gather Verse

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Commandlets/GatherTextFromAssetsCommandlet.h:105

Scope (from outer to inner):

file
class        class UGatherTextFromAssetsCommandlet : public UGatherTextCommandletBase

Source code excerpt:

	TArray<FString> ModulesToPreload;
	TArray<FString> IncludePathFilters;
	TArray<FString> CollectionFilters;
	TArray<FString> ExcludePathFilters;
	TArray<FString> PackageFileNameFilters;
	TArray<FString> ExcludeClassNames;
	TArray<FString> ManifestDependenciesList;

	TArray<FPackagePendingGather> PackagesPendingGather;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/GatherTextFromAssetsCommandlet.cpp:532

Scope: file

Source code excerpt:

	FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
	ICollectionManager& CollectionManager = CollectionManagerModule.Get();
	for (const FString& CollectionName : CollectionFilters)
	{
		if (!CollectionManager.GetObjectsInCollection(FName(*CollectionName), ECollectionShareType::CST_All, InOutFilter.SoftObjectPaths, ECollectionRecursionFlags::SelfAndChildren))
		{
			UE_LOG(LogGatherTextFromAssetsCommandlet, Error, TEXT("Failed get objects in specified collection: %s"), *CollectionName);
			bHasFailedToGetACollection = true;
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/GatherTextFromAssetsCommandlet.cpp:1488

Scope (from outer to inner):

file
function     bool UGatherTextFromAssetsCommandlet::ConfigureFromScript

Source code excerpt:


	// Collections
	GetStringArrayFromConfig(*SectionName, TEXT("CollectionFilters"), CollectionFilters, GatherTextConfigPath);
	for (const FString& CollectionName : CollectionFilters)
	{
		FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
		ICollectionManager& CollectionManager = CollectionManagerModule.Get();

		const bool bDoesCollectionExist = CollectionManager.CollectionExists(FName(*CollectionName), ECollectionShareType::CST_All);
		if (!bDoesCollectionExist)