PackageFileNameFilters

PackageFileNameFilters

#Overview

name: PackageFileNameFilters

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PackageFileNameFilters is to specify which file types should be included when gathering text for localization in Unreal Engine 5. It is primarily used in the localization and asset gathering systems.

This setting variable is relied upon by the Localization module and the UnrealEd module, specifically in the GatherTextFromAssetsCommandlet. It is used to filter which asset files should be processed for text extraction during the localization process.

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

PackageFileNameFilters interacts with other variables such as ExcludePathFilters, CollectionFilters, and ExcludeClassNames to determine which assets should be processed for localization.

Developers must be aware that this variable expects wildcard patterns for file names (e.g., “.uasset”, “.umap”). It’s crucial to include all relevant file extensions to ensure all desired assets are processed.

Best practices when using this variable include:

  1. Always specify at least one filter to avoid errors.
  2. Use wildcard patterns to cover all relevant file types (e.g., “.uasset” for most assets, “.umap” for levels).
  3. Consider the performance impact of including too many file types, and balance it with the need for comprehensive text gathering.
  4. Regularly review and update the filters to ensure they cover all necessary asset types as your project evolves.
  5. Use in conjunction with other filtering mechanisms (like ExcludePathFilters) for more precise control over which assets are processed.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Localization/Editor.ini:46, section: [GatherTextStep1]

Location: <Workspace>/Engine/Config/Localization/Editor.ini:47, section: [GatherTextStep1]

Location: <Workspace>/Engine/Config/Localization/EditorTutorials.ini:36, section: [GatherTextStep0]

Location: <Workspace>/Engine/Config/Localization/EditorTutorials.ini:37, section: [GatherTextStep0]

Location: <Workspace>/Engine/Config/Localization/EditorTutorials.ini:38, section: [GatherTextStep0]

Location: <Workspace>/Engine/Config/Localization/Engine.ini:59, section: [GatherTextStep1]

Location: <Workspace>/Engine/Config/Localization/Engine.ini:60, section: [GatherTextStep1]

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

Location: <Workspace>/Projects/Lyra/Config/Localization/Game_Gather.ini:52, 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:381

Scope (from outer to inner):

file
namespace    LocalizationConfigurationScript
function     FLocalizationConfigurationScript GenerateGatherTextConfigFile

Source code excerpt:

			for (const auto& FileExtension : Target->Settings.GatherFromPackages.FileExtensions)
			{
				ConfigSection.Add( TEXT("PackageFileNameFilters"), FString::Printf( TEXT("*.%s"), *FileExtension.Pattern) );
			}

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

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

Scope (from outer to inner):

file
namespace    UserGeneratedContentLocalization
function     bool ExportLocalization

Source code excerpt:

				ConfigSection.Add(TEXT("CommandletClass"), TEXT("GatherTextFromAssets"));

				ConfigSection.Add(TEXT("PackageFileNameFilters"), TEXT("*.uasset"));
				ConfigSection.Add(TEXT("PackageFileNameFilters"), TEXT("*.umap"));

				ConfigSection.Add(TEXT("IncludePathFilters"), FPaths::ConvertRelativePathToFull(FPaths::Combine(Plugin->GetContentDir(), TEXT("*"))));

				ConfigSection.Add(TEXT("ExcludePathFilters"), FPaths::ConvertRelativePathToFull(FPaths::Combine(Plugin->GetContentDir(), TEXT("Localization"), TEXT("*"))));
				ConfigSection.Add(TEXT("ExcludePathFilters"), FPaths::ConvertRelativePathToFull(FPaths::Combine(Plugin->GetContentDir(), TEXT("L10N"), TEXT("*"))));

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

Scope (from outer to inner):

file
class        class UGatherTextFromAssetsCommandlet : public UGatherTextCommandletBase

Source code excerpt:

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

	TArray<FPackagePendingGather> PackagesPendingGather;

	/** Run a GC if the free system memory is less than this value (or zero to disable) */

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

Scope (from outer to inner):

file
function     void UGatherTextFromAssetsCommandlet::FilterAssetsBasedOnIncludeExcludePaths
lambda-function

Source code excerpt:

			{
				bool HasPassedAnyFileNameFilter = false;
				for (const FString& PackageFileNameFilter : PackageFileNameFilters)
				{
					if (PackageFileName.MatchesWildcard(PackageFileNameFilter))
					{
						HasPassedAnyFileNameFilter = true;
						break;
					}

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

Scope (from outer to inner):

file
function     bool UGatherTextFromAssetsCommandlet::ConfigureFromScript

Source code excerpt:


	// PackageNameFilters
	GetStringArrayFromConfig(*SectionName, TEXT("PackageFileNameFilters"), PackageFileNameFilters, GatherTextConfigPath);

	// PackageExtensions (DEPRECATED)
	{
		TArray<FString> PackageExtensions;
		GetStringArrayFromConfig(*SectionName, TEXT("PackageExtensions"), PackageExtensions, GatherTextConfigPath);
		if (PackageExtensions.Num())
		{
			PackageFileNameFilters.Append(PackageExtensions);
			UE_LOG(LogGatherTextFromAssetsCommandlet, Warning, TEXT("PackageExtensions detected in section %s. PackageExtensions is deprecated, please use PackageFileNameFilters."), *SectionName);
		}
	}

	if (PackageFileNameFilters.Num() == 0)
	{
		UE_LOG(LogGatherTextFromAssetsCommandlet, Error, TEXT("No package file name filters in section %s."), *SectionName);
		bHasFatalError = true;
	}

	// Recursive asset class exclusion