Files

95 lines
4.6 KiB
C#
Raw Permalink Normal View History

Localization: Introduced the experimental LocalizationTargetEditor UAT command. This command allows users to create, update, delete and query localization targets in the Engine or project. The LocalizationTargetEditor UAT command is set up to have a series of sub-commands which can be executed with different parameters. This allows the LocalizationTargetEditor to be extensible to users for specialized localization target operations. - Introduced the LocalizationTargetCommand abstract base class. This class is what all othe LocalizationTargetEditor sub-commands should be drived from. A scan of all sub-classes of LocalizationTargetCommand will be scanned for to determine all available localization target commands. - Introduced the PluginLocalizationTargetCommand abstract base class. All commands to be operated on plugins should derive from this class. - Introduced the NewPluginLocalizationTarget sub-command which will create localization config files for plugins and make the necessary updates to .uplugin files. All plugins under a provided directory can be operated on at a time to batch create the necessary localization config files. - The NewPluginLocalizationTarget sub-command has perforce integration and can automatically add/check out all files that have been created/edited. - Introduced a number of classes to encapsulate all the data in the various localization config files. This allows for generation of localization config files from code. - Introduced the LocalizationConfigFileBuilder and LocalizationConfigFileGenerator base classes. These classes and their sub-classes are used to generate localization config files in the correct format provided the config file data. Current support is only for modular localization config files. However, the LocalizationConfigFileBuilder can also be used to generate Monolithic localization config files if necessary.also #rb: Jamie.Dale #jira: UE-194872, UE-194873, UE-194874, #test Used the NewPluginLocalizationTarget sub-command to generate a number of plugins. The generated localization config files yield correct localization gather results and the plugin .locres file was successfully loaded at runtime to display the correct localized text. [CL 28424727 by leon huang in ue5-main branch]
2023-10-03 14:44:56 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
using AutomationTool;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Localization: Introduced the experimental LocalizationTargetEditor UAT command. This command allows users to create, update, delete and query localization targets in the Engine or project. The LocalizationTargetEditor UAT command is set up to have a series of sub-commands which can be executed with different parameters. This allows the LocalizationTargetEditor to be extensible to users for specialized localization target operations. - Introduced the LocalizationTargetCommand abstract base class. This class is what all othe LocalizationTargetEditor sub-commands should be drived from. A scan of all sub-classes of LocalizationTargetCommand will be scanned for to determine all available localization target commands. - Introduced the PluginLocalizationTargetCommand abstract base class. All commands to be operated on plugins should derive from this class. - Introduced the NewPluginLocalizationTarget sub-command which will create localization config files for plugins and make the necessary updates to .uplugin files. All plugins under a provided directory can be operated on at a time to batch create the necessary localization config files. - The NewPluginLocalizationTarget sub-command has perforce integration and can automatically add/check out all files that have been created/edited. - Introduced a number of classes to encapsulate all the data in the various localization config files. This allows for generation of localization config files from code. - Introduced the LocalizationConfigFileBuilder and LocalizationConfigFileGenerator base classes. These classes and their sub-classes are used to generate localization config files in the correct format provided the config file data. Current support is only for modular localization config files. However, the LocalizationConfigFileBuilder can also be used to generate Monolithic localization config files if necessary.also #rb: Jamie.Dale #jira: UE-194872, UE-194873, UE-194874, #test Used the NewPluginLocalizationTarget sub-command to generate a number of plugins. The generated localization config files yield correct localization gather results and the plugin .locres file was successfully loaded at runtime to display the correct localized text. [CL 28424727 by leon huang in ue5-main branch]
2023-10-03 14:44:56 -04:00
using UnrealBuildTool;
using static AutomationTool.CommandUtils;
namespace EpicGames.Localization
{
public abstract class PluginLocalizationTargetCommand : LocalizationTargetCommand
{
public string UERootDirectory { get; protected set; } = "";
public string UEProjectDirectory { get; protected set; } = "";
public string UEProjectName { get; protected set; } = "";
public HashSet<string> IncludePlugins { get; protected set; } = new HashSet<string>();
public HashSet<string> ExcludePlugins { get; protected set; } = new HashSet<string>();
protected override void BuildHelpArguments(StringBuilder builder)
{
base.BuildHelpArguments(builder);
builder.AppendLine("UERootDirectory - Optional root directory for the Unreal Engine. This is usually one level above your project directory. Defaults to CmdEnv.LocalRoot");
builder.AppendLine("UEProjectDirectory - Required relative path from UERootDirectory to the project. This should be your project directory that contains the Plugins directory.");
builder.AppendLine("UEProjectName - An optional name of the project the plugin is under. If blank, this implies the plugin is under Engine.");
// Include plugins
builder.AppendLine("IncludePlugins - An optional comma separated list of plugins to operate on. E.g PluginA,PluginB,PluginC");
builder.AppendLine("IncludePluginsDirectory - An optional relative directory to UEProjectDirectory. All plugins under this directory will be operated on if they are not excluded. E.g Plugins/PluginFolderA.");
builder.AppendLine("ExcludePlugins - A comma separated list of plugins to exclude from being operated on. E.g PluginA,BpluginB,PluginC");
builder.AppendLine("ExcludePluginsDirectory - An optional relative directory from UEProjectDirectory. All plugins under this directory will be excluded from being operated on. E.g Plugin/DirectoryToExclude");
}
Localization: Introduced the experimental LocalizationTargetEditor UAT command. This command allows users to create, update, delete and query localization targets in the Engine or project. The LocalizationTargetEditor UAT command is set up to have a series of sub-commands which can be executed with different parameters. This allows the LocalizationTargetEditor to be extensible to users for specialized localization target operations. - Introduced the LocalizationTargetCommand abstract base class. This class is what all othe LocalizationTargetEditor sub-commands should be drived from. A scan of all sub-classes of LocalizationTargetCommand will be scanned for to determine all available localization target commands. - Introduced the PluginLocalizationTargetCommand abstract base class. All commands to be operated on plugins should derive from this class. - Introduced the NewPluginLocalizationTarget sub-command which will create localization config files for plugins and make the necessary updates to .uplugin files. All plugins under a provided directory can be operated on at a time to batch create the necessary localization config files. - The NewPluginLocalizationTarget sub-command has perforce integration and can automatically add/check out all files that have been created/edited. - Introduced a number of classes to encapsulate all the data in the various localization config files. This allows for generation of localization config files from code. - Introduced the LocalizationConfigFileBuilder and LocalizationConfigFileGenerator base classes. These classes and their sub-classes are used to generate localization config files in the correct format provided the config file data. Current support is only for modular localization config files. However, the LocalizationConfigFileBuilder can also be used to generate Monolithic localization config files if necessary.also #rb: Jamie.Dale #jira: UE-194872, UE-194873, UE-194874, #test Used the NewPluginLocalizationTarget sub-command to generate a number of plugins. The generated localization config files yield correct localization gather results and the plugin .locres file was successfully loaded at runtime to display the correct localized text. [CL 28424727 by leon huang in ue5-main branch]
2023-10-03 14:44:56 -04:00
protected override bool ParseCommandLine()
{
if (!base.ParseCommandLine())
{
return false;
}
UERootDirectory = _commandLineHelper.ParseParamValue("UERootDirectory");
if (String.IsNullOrEmpty(UERootDirectory))
{
UERootDirectory = CommandUtils.CmdEnv.LocalRoot;
}
UEProjectName = _commandLineHelper.ParseParamValue("UEProject");
UEProjectDirectory = _commandLineHelper.ParseRequiredStringParam("UEProjectDirectory");
// getting the plugins
string includePluginsString = _commandLineHelper.ParseParamValue("IncludePlugins");
if (!String.IsNullOrEmpty(includePluginsString))
{
foreach (string plugin in includePluginsString.Split(","))
{
IncludePlugins.Add(plugin.Trim());
}
}
string excludePluginsString = _commandLineHelper.ParseParamValue("ExcludePlugins");
if (!String.IsNullOrEmpty(excludePluginsString))
{
foreach (string plugin in excludePluginsString.Split(","))
{
ExcludePlugins.Add(plugin.Trim());
}
}
string projectPluginDirectory = Path.Combine(UERootDirectory, UEProjectDirectory, "Plugins");
PluginType pluginType = String.IsNullOrEmpty(UEProjectName) ? PluginType.Engine : PluginType.Project;
// The provided path should be relative to the project directory
string includePluginsDirectoryString = _commandLineHelper.ParseParamValue("IncludePluginsDirectory");
if (!String.IsNullOrEmpty(includePluginsDirectoryString))
{
// @TODOLocalization: May need to manipulate passed in string to replace directory separators on various platforms
string IncludePluginsDirectoryAbsolutePath = Path.Combine(UERootDirectory, UEProjectDirectory, includePluginsDirectoryString);
Logger.LogInformation($"Including plugins under '{IncludePluginsDirectoryAbsolutePath}' directory.");
IncludePlugins.UnionWith(LocalizationUtilities.GetPluginNamesUnderDirectory(IncludePluginsDirectoryAbsolutePath, projectPluginDirectory, pluginType));
}
string excludePluginsDirectoryString = _commandLineHelper.ParseParamValue("ExcludePluginsDirectory");
if (!String.IsNullOrEmpty(excludePluginsDirectoryString))
{
string excludePluginsDirectoryAbsolutePath = Path.Combine(UERootDirectory, UEProjectDirectory, excludePluginsDirectoryString);
Logger.LogInformation($"Excluding plugins under '{excludePluginsDirectoryAbsolutePath}' directory.");
ExcludePlugins.UnionWith(LocalizationUtilities.GetPluginNamesUnderDirectory(excludePluginsDirectoryAbsolutePath, projectPluginDirectory, pluginType));
}
return true;
}
}
}