Files
UnrealEngineUWP/Engine/Source/Runtime/Projects/Public/LocalizationDescriptor.h
leon huang 95acda43f6 Localization:
Introduced opt in localization for plugins. Plugins can be set to never have localization config files generated, auto-generated or have the localization pipeline use the user generated localization config files.
- All existing plugins with localization targets will be retrofitted to have a LocalizationConfigGenerationPolicy of Never to match current behavior.
- Introduced the LocalizationConfigGenerationPolicy enum to plugin descriptors and LocalizationTargetDescriptors. This controls whether plugin localization targets use user generated localization config files, auto-generated localization config files or if the plugin is never to have localization config files and thus not localized.
- Introduced a step in the Localize UAT command to auto-generate localization config files with default settings for plugins that opt into the auto-generation feature.
- Added a clean up step in the Localize uAT command to delete all auto-generated files and folders from a run of the command.
- Added a -PreserveAutoGeneratedResources flag for the Localize UAT command to preserve the auto-generated files and directories for debugging.
-Updated both the C# and C++ version of the LocalizationTargetDescriptor to contain the new LocalizationConfigGenerationPolicy and have them read and written from the plugin descriptor files.
- Updated the NewPluginLocalizationTarget command under the LocalizationTargetEditor UAT command to accept a LocalizationConfigGenerationPolicy as a command line argument for all plugin localization targets to be created.
If the parameter is not specified, the parameter defaults to the Auto LocalizationConfigGenerationPolicy for all the plugins specified.
#rb: Jamie.Dale
#jira: UE-194880, UE-194879
#test Used the NewPluginLocalizationTarget sub-command to create plugins with an auto localization target. Used the Localize UAT command to perform a gather for such a plugin. Config files were indeed generated, the plugin was gathered and the loc data stored in PluginName/Content/Localization and then the config files were deleted. No fuss, no muss

[CL 30172150 by leon huang in ue5-main branch]
2023-12-06 19:03:56 -05:00

131 lines
5.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "CoreMinimal.h"
#include "HAL/Platform.h"
#include "Serialization/JsonWriter.h"
class FJsonObject;
class FText;
/**
* Policy by which the localization data associated with a target should be loaded.
*/
namespace ELocalizationTargetDescriptorLoadingPolicy
{
enum Type
{
/** The localization data will never be loaded automatically. */
Never,
/** The localization data will always be loaded automatically. */
Always,
/** The localization data will only be loaded when running the editor. Use if the target localizes the editor. */
Editor,
/** The localization data will only be loaded when running the game. Use if the target localizes your game. */
Game,
/** The localization data will only be loaded if the editor is displaying localized property names. */
PropertyNames,
/** The localization data will only be loaded if the editor is displaying localized tool tips. */
ToolTips,
/** NOTE: If you add a new value, make sure to update the ToString() method below!. */
Max,
};
/**
* Converts a string to a ELocalizationTargetDescriptorLoadingPolicy::Type value
*
* @param The string to convert to a value
* @return The corresponding value, or 'Max' if the string is not valid.
*/
PROJECTS_API ELocalizationTargetDescriptorLoadingPolicy::Type FromString(const TCHAR *Text);
/**
* Returns the name of a localization loading policy.
*
* @param The value to convert to a string
* @return The string representation of this enum value
*/
PROJECTS_API const TCHAR* ToString(const ELocalizationTargetDescriptorLoadingPolicy::Type Value);
};
/** How the localization target's localization config files are generated during the localization gather pipeline.*/
namespace ELocalizationConfigGenerationPolicy
{
enum Type
{
/** This localization target does not have localization config files associated with it and no localization content files will be generated for it during the localizaiton pipeline.*/
Never,
/** The user has provided localization config files for this localization target and they will be used to generate the localization content files for the localization target.*/
User,
/** Temporary localization config files will be generated for the localization target during the localization pipeline to generate the localization content files. After the localization pipeline is complete, the temporary files will be deleted.*/
Auto,
/** NOTE: If you add a new value, make sure to update the ToString() method below!. */
Max,
};
/**
* Converts a string to a ELocalizationConfigGenerationPolicy::Type value
*
* @param The string to convert to a value
* @return The corresponding value, or 'Max' if the string is not valid.
*/
PROJECTS_API ELocalizationConfigGenerationPolicy::Type FromString(const TCHAR* Text);
/**
* Returns the name of a ELocalizationConfigGenerationPolicy::Type
*
* @param The value to convert to a string
* @return The string representation of this enum value
*/
PROJECTS_API const TCHAR* ToString(const ELocalizationConfigGenerationPolicy::Type Value);
};
/**
* Description of a localization target.
*/
struct FLocalizationTargetDescriptor
{
/** Name of this target */
FString Name;
/** When should the localization data associated with a target should be loaded? */
ELocalizationTargetDescriptorLoadingPolicy::Type LoadingPolicy;
/** How the localizationc config files associated with the localization target are generated */
ELocalizationConfigGenerationPolicy::Type ConfigGenerationPolicy;
/** Normal constructor */
PROJECTS_API FLocalizationTargetDescriptor(FString InName = FString(), ELocalizationTargetDescriptorLoadingPolicy::Type InLoadingPolicy = ELocalizationTargetDescriptorLoadingPolicy::Never, ELocalizationConfigGenerationPolicy::Type InGenerationPolicy = ELocalizationConfigGenerationPolicy::Never);
/** Reads a descriptor from the given JSON object */
PROJECTS_API bool Read(const FJsonObject& InObject, FText* OutFailReason = nullptr);
/** Reads a descriptor from the given JSON object */
PROJECTS_API bool Read(const FJsonObject& InObject, FText& OutFailReason);
/** Reads an array of targets from the given JSON object */
static PROJECTS_API bool ReadArray(const FJsonObject& InObject, const TCHAR* InName, TArray<FLocalizationTargetDescriptor>& OutTargets, FText* OutFailReason = nullptr);
/** Reads an array of targets from the given JSON object */
static PROJECTS_API bool ReadArray(const FJsonObject& InObject, const TCHAR* InName, TArray<FLocalizationTargetDescriptor>& OutTargets, FText& OutFailReason);
/** Writes a descriptor to JSON */
PROJECTS_API void Write(TJsonWriter<>& Writer) const;
/** Updates the given json object with values in this descriptor */
PROJECTS_API void UpdateJson(FJsonObject& JsonObject) const;
/** Writes an array of targets to JSON */
static PROJECTS_API void WriteArray(TJsonWriter<>& Writer, const TCHAR* ArrayName, const TArray<FLocalizationTargetDescriptor>& Descriptors);
/** Updates an array of descriptors in the specified JSON field (indexed by name) */
static PROJECTS_API void UpdateArray(FJsonObject& JsonObject, const TCHAR* ArrayName, const TArray<FLocalizationTargetDescriptor>& Descriptors);
/** Returns true if we should load this localization target based upon the current runtime environment */
PROJECTS_API bool ShouldLoadLocalizationTarget() const;
};