Files
UnrealEngineUWP/Engine/Source/Editor/Localization/Private/LocalizationConfigurationScript.cpp

662 lines
25 KiB
C++
Raw Normal View History

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "LocalizationPrivatePCH.h"
#include "LocalizationConfigurationScript.h"
#include "LocalizationTargetTypes.h"
#include "LocalizationSettings.h"
namespace
{
FString GetConfigDir(const ULocalizationTarget* const Target)
{
return Target->IsMemberOfEngineTargetSet() ? FPaths::EngineConfigDir() : FPaths::GameConfigDir();
}
FString GetContentDir(const ULocalizationTarget* const Target)
{
return Target->IsMemberOfEngineTargetSet() ? FPaths::EngineContentDir() : FPaths::GameContentDir();
}
}
namespace LocalizationConfigurationScript
{
FString MakePathRelativeForCommandletProcess(const FString& Path, const bool IsUsingProjectFile)
{
FString Result = Path;
const FString ProjectDir = !IsUsingProjectFile ? FPaths::EngineDir() : FPaths::GameDir();
if (!FPaths::MakePathRelativeTo(Result, *ProjectDir))
{
Result = FPaths::ConvertRelativePathToFull(Path);
}
return Result;
}
FString GetScriptDirectory(const ULocalizationTarget* const Target)
{
return GetConfigDir(Target) / TEXT("Localization");
}
FString GetDataDirectory(const ULocalizationTarget* const Target)
{
return GetContentDir(Target) / TEXT("Localization") / Target->Settings.Name;
}
TArray<FString> GetScriptPaths(const ULocalizationTarget* const Target)
{
TArray<FString> Result;
Result.Add(GetGatherScriptPath(Target));
Result.Add(GetImportScriptPath(Target));
Result.Add(GetExportScriptPath(Target));
Result.Add(GetWordCountReportScriptPath(Target));
return Result;
}
FString GetManifestPath(const ULocalizationTarget* const Target)
{
return GetDataDirectory(Target) / FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("manifest") );
}
FString GetArchivePath(const ULocalizationTarget* const Target, const FString& CultureName)
{
return GetDataDirectory(Target) / CultureName / FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("archive") );
}
FString GetDefaultPOFileName(const ULocalizationTarget* const Target)
{
return FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("po") );
}
FString GetDefaultPOPath(const ULocalizationTarget* const Target, const FString& CultureName)
{
return GetDataDirectory(Target) / CultureName / GetDefaultPOFileName(Target);
}
FString GetLocResPath(const ULocalizationTarget* const Target, const FString& CultureName)
{
return GetDataDirectory(Target) / CultureName / FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("locres") );
}
FString GetWordCountCSVPath(const ULocalizationTarget* const Target)
{
return GetDataDirectory(Target) / FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("csv") );
}
FString GetConflictReportPath(const ULocalizationTarget* const Target)
{
return GetDataDirectory(Target) / FString::Printf( TEXT("%s_Conflicts.%s"), *Target->Settings.Name, TEXT("txt") );
}
FLocalizationConfigurationScript GenerateGatherScript(const ULocalizationTarget* const Target)
{
FLocalizationConfigurationScript Script;
const FString ConfigDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetConfigDir(Target), !Target->IsMemberOfEngineTargetSet());
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// CommonSettings
{
FConfigSection& ConfigSection = Script.CommonSettings();
const ULocalizationTargetSet* const LocalizationTargetSet = GetDefault<ULocalizationTargetSet>(ULocalizationTargetSet::StaticClass());
for (const FGuid& TargetDependencyGuid : Target->Settings.TargetDependencies)
{
TArray<ULocalizationTarget*> AllLocalizationTargets;
ULocalizationTargetSet* EngineTargetSet = ULocalizationSettings::GetEngineTargetSet();
if (EngineTargetSet != LocalizationTargetSet)
{
AllLocalizationTargets.Append(EngineTargetSet->TargetObjects);
}
AllLocalizationTargets.Append(LocalizationTargetSet->TargetObjects);
ULocalizationTarget* const * OtherTarget = AllLocalizationTargets.FindByPredicate([&TargetDependencyGuid](ULocalizationTarget* const InOtherTarget)->bool{return InOtherTarget->Settings.Guid == TargetDependencyGuid;});
if (OtherTarget)
{
ConfigSection.Add( TEXT("ManifestDependencies"), MakePathRelativeForCommandletProcess(GetManifestPath(*OtherTarget), !Target->IsMemberOfEngineTargetSet()) );
}
}
for (const FFilePath& Path : Target->Settings.AdditionalManifestDependencies)
{
ConfigSection.Add( TEXT("ManifestDependencies"), MakePathRelativeForCommandletProcess(Path.FilePath, !Target->IsMemberOfEngineTargetSet()) );
}
for (const FString& ModuleName : Target->Settings.RequiredModuleNames)
{
ConfigSection.Add( TEXT("ModulesToPreload"), ModuleName );
}
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
ConfigSection.Add( TEXT("ManifestName"), FPaths::GetCleanFilename(GetManifestPath(Target)) );
ConfigSection.Add( TEXT("ArchiveName"), FPaths::GetCleanFilename(GetArchivePath(Target, FString())) );
if (Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex))
{
ConfigSection.Add( TEXT("NativeCulture"), Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName );
}
for (const FCultureStatistics& CultureStatistics : Target->Settings.SupportedCulturesStatistics)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), CultureStatistics.CultureName );
}
}
uint32 GatherTextStepIndex = 0;
// GatherTextFromSource
if (Target->Settings.GatherFromTextFiles.IsEnabled)
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GatherTextFromSource") );
// Include Paths
for (const auto& IncludePath : Target->Settings.GatherFromTextFiles.SearchDirectories)
{
ConfigSection.Add( TEXT("SearchDirectoryPaths"), IncludePath.Path );
}
// Exclude Paths
ConfigSection.Add( TEXT("ExcludePathFilters"), TEXT("Config/Localization/*") );
for (const auto& ExcludePath : Target->Settings.GatherFromTextFiles.ExcludePathWildcards)
{
ConfigSection.Add( TEXT("ExcludePathFilters"), ExcludePath.Pattern );
}
// Source File Search Filters
for (const auto& FileExtension : Target->Settings.GatherFromTextFiles.FileExtensions)
{
ConfigSection.Add( TEXT("FileNameFilters"), FString::Printf( TEXT("*.%s"), *FileExtension.Pattern) );
}
Copying //UE4/Orion-Staging to //UE4/Main (Origin: //Orion/Dev-General @2826496) #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2826201 on 2016/01/13 by Zabir.Hoque Add more verbose logging to try to understand #OR-11297 #lockdown Andrew.Grant #CodeReview Marcus.Wassmer #RB none #TESTS compiled Win64 debug editor, ran agora_p Change 2826170 on 2016/01/13 by Marcus.Wassmer Flush unloaded resource properly in LoadMap #codereview Gil.Gribb #rb none #test cycling game. memory is freed properly now. #lockdown Andrew.Grant Change 2826135 on 2016/01/12 by Michael.Noland Orion: Improve login screen on PC to reduce the potential impact of framerate on data center ping calculation - Disabled async streaming for the duration of the QOS ping measurement to avoid hitches - Added a circular throbber in the top left corner of the login screen indicating that something is async streaming (as a diagnostic tool for users affected by the datacenter ping, can be removed in the future) - Added logging of the current average frame time when the datacenter ping is finalized - Added a 'Pick Ideal Settings' button to the login screen (note: on the actual screen, not the login widget, so it will not appear on PS4) #jira OR-12453 #rb paul.moore #tests Ran a QOS server and client and verified that the new logging is occurring, tried out the new benchmark button, etc... Merging CL# 2826128 using //Orion/Main_to_//Orion/Dev-General Change 2826131 on 2016/01/12 by Michael.Noland #UE4 - added print out of MS/FPS during Qos ping evaluation #rb michael.noland #tests loaded up through login screen to see output Merging CL# 2825678 using //Orion/Main_to_//Orion/Dev-General Change 2826128 on 2016/01/12 by Michael.Noland Orion: Improve login screen on PC to reduce the potential impact of framerate on data center ping calculation - Disabled async streaming for the duration of the QOS ping measurement to avoid hitches - Added a circular throbber in the top left corner of the login screen indicating that something is async streaming (as a diagnostic tool for users affected by the datacenter ping, can be removed in the future) - Added logging of the current average frame time when the datacenter ping is finalized - Added a 'Pick Ideal Settings' button to the login screen (note: on the actual screen, not the login widget, so it will not appear on PS4) #jira OR-12453 #rb paul.moore #tests Ran a QOS server and client and verified that the new logging is occurring, tried out the new benchmark button, etc... Merging CL# 2826116 using //Orion/Release-Next->//Orion/Main Change 2826116 on 2016/01/12 by Michael.Noland Orion: Improve login screen on PC to reduce the potential impact of framerate on data center ping calculation - Disabled async streaming for the duration of the QOS ping measurement to avoid hitches - Added a circular throbber in the top left corner of the login screen indicating that something is async streaming (as a diagnostic tool for users affected by the datacenter ping, can be removed in the future) - Added logging of the current average frame time when the datacenter ping is finalized - Added a 'Pick Ideal Settings' button to the login screen (note: on the actual screen, not the login widget, so it will not appear on PS4) #jira OR-12453 #rb paul.moore #tests Ran a QOS server and client and verified that the new logging is occurring, tried out the new benchmark button, etc... #lockdown andrew.grant #codereview josh.markiewicz Change 2825772 on 2016/01/12 by Dmitry.Rekman Linux signal handling improvements. - Switch crash handlers to use "crash malloc" (preallocated memory) on crash. - Remove unnecessary memory allocations from graceful termination handler. #rb none #tests Run the Linux server and crashed it a few times. #codereview David.Vossel, Michael.Trepka Change 2825768 on 2016/01/12 by Josh.Markiewicz #UE4 - added print out of MS/FPS during Qos ping evaluation #rb michael.noland #tests loaded up through login screen to see output Change 2825703 on 2016/01/12 by Brian.Karis Switched on new motion blur. Set temporal AA sharpness to 1. #rb none #TESTS editor Change 2825689 on 2016/01/12 by Lina.Halper Fix for get animation notify crash https://jira.ol.epicgames.net/browse/OR-12248 https://jira.ol.epicgames.net/browse/OR-12348 - Also fixed the crash in preview of persona due to blend sample cache contains previous animation data - Also fixed blend space player to reinitialize cache data - The main issue is marker doesn't clamp the length, causing notifies ensure to trigger. #rb : Laurent.Delayen #tests: 10 Sparrows bot match for long time #code review: Martin.Wilson #lockdown: Andrew.Grant Change 2825680 on 2016/01/12 by Martin.Mittring fixed all cases with r.Tonemapper.ScreenPercentage, ScreenPercentage, Fringe, Vignette, ViewRect, flickering with transluceny (View members have been modified while other thread was reading) #rb:Olaf.Piesche, David.Hill #test: PC, many cases Change 2825579 on 2016/01/12 by Chris.Bunner Force shadow shape bone indices on the required update list. #rb Lina.Halper, Rolando.Caloca #tests Editor #codereview Daniel.Wright #jira OR-12339 Change 2825443 on 2016/01/12 by Martin.Mittring
2016-01-14 08:11:47 -05:00
ConfigSection.Add( TEXT("ShouldGatherFromEditorOnlyData"), Target->Settings.GatherFromTextFiles.ShouldGatherFromEditorOnlyData ? TEXT("true") : TEXT("false") );
}
// GatherTextFromAssets
if (Target->Settings.GatherFromPackages.IsEnabled)
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GatherTextFromAssets") );
// Include Paths
for (const auto& IncludePath : Target->Settings.GatherFromPackages.IncludePathWildcards)
{
ConfigSection.Add( TEXT("IncludePathFilters"), IncludePath.Pattern );
}
// Exclude Paths
ConfigSection.Add( TEXT("ExcludePathFilters"), TEXT("Content/Localization/*") );
for (const auto& ExcludePath : Target->Settings.GatherFromPackages.ExcludePathWildcards)
{
ConfigSection.Add( TEXT("ExcludePathFilters"), ExcludePath.Pattern );
}
// Package Extensions
for (const auto& FileExtension : Target->Settings.GatherFromPackages.FileExtensions)
{
ConfigSection.Add( TEXT("PackageFileNameFilters"), FString::Printf( TEXT("*.%s"), *FileExtension.Pattern) );
}
ConfigSection.Add( TEXT("ShouldGatherFromEditorOnlyData"), Target->Settings.GatherFromPackages.ShouldGatherFromEditorOnlyData ? TEXT("true") : TEXT("false") );
Copying //UE4/Orion-Staging to //UE4/Main (Origin //Orion/Dev-General @ 2861092) #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2861045 on 2016/02/09 by Marcus.Wassmer Fix debug editor crash from async compute creating commands when it shouldn't. #rb none #test debug editor Change 2861030 on 2016/02/09 by Michael.Noland Engine: Added support for debugging safe zones (visualization on any platform and simulation on platforms that don't natively provide safe zone information) r.DebugSafeZone.Mode controls the debug visualization overlay (0..2, default 0) - 0: Do not display the safe zone overlay - 1: Display the overlay for the title safe zone - 2: Display the overlay for the action safe zone r.DebugSafeZone.OverlayAlpha controls how opaque the debug visualization overlay is (0..1, default 0.3) On platforms that don't natively support safe zones, you can simulate a safe zone for quick/easy testing in the editor: - r.DebugSafeZone.TitleRatio controls the title safe zone margins returned in FDisplayMetrics - r.DebugActionZone.ActionRatio controls the action safe zone margins returned in FDisplayMetrics - These both range from 0..1, and default to 1 indicating 100% of the display is safe. A typical test value would be 0.9 #codereview josh.adams #rb marcus.wassmer #tests Tested on Win64 uncooked and PS4 cooked (front-end and game) Change 2860923 on 2016/02/09 by Andrew.Grant Fix client warning about HTTPChunkInstaller module not existing #rb none #tests ran Win64 client Change 2860852 on 2016/02/09 by Daniel.Wright Fixed crash enabling capsule direct shadows in BP #rb Nick.Penwarden #tests Editor Change 2860842 on 2016/02/09 by Marcus.Wassmer MallocLeakDetection proxy #rb Steve.Robb #test PS4/PC testing all commands. Change 2860744 on 2016/02/09 by Josh.Markiewicz #UE4 - fixed possible crash when refresh auth with invalid response #rb sam.zamani #tests login flow #codereview justin.sargent, joe.wilcox, pter.knepley, ben.zeigler Change 2860739 on 2016/02/09 by Laurent.Delayen Sync Markers - Reset SyncGroups every frame. - ::GetSyncGroupPosition() makes sure there is a valid MarkerSyncContext. => Fixes SyncGroup returning 'valid' positions for TransitionLeaders that were not in between sync markers. #rb martin.wilson #codereview lina.halper #tests new riftmage and kurohane networked in PIE Change 2860736 on 2016/02/09 by Daniel.Lamb Fixed issue with iterative cook on the fly invalidating cooked content all the time. #rb Marcus.Wassmer #test Cook on the fly iterative ps4 Change 2860598 on 2016/02/09 by Joe.Graf Simple log category change to match existing log messages in LoadMap #rb: n/a #test: loading, cooking, game Change 2860559 on 2016/02/09 by Zak.Middleton #orion - Add flag to AIController to control whether it copies the Pawn rotation to ControlRotation if there is no focus point. #rb Lukasz.Furman #tests PIE ded server AI with lanes Change 2860462 on 2016/02/09 by Marc.Audy Build system improvements * Added details to Empty manifest file save error * Removed redundent pseudo-dependencies from -showdependency output * Monolithic Kinds now a set and branch hacker can specify kind not to build #rb Ben.Marsh #tests Preflight Change 2860434 on 2016/02/09 by David.Ratti NaN checks: -Targeting mode checks in orion code -Changed the AActor::SetTransform NaN check so that the logging is included in the NaN ensure (rather than getting cut off from the log afterwards). #rb FrankG #tests golden path vs bots Change 2860390 on 2016/02/09 by Michael.Trepka Adjust 3D rendering resolution so that it stays approximately the same when user switches display modes #rb none #tests Tested editor build on PC Change 2860364 on 2016/02/09 by Justin.Sargent Removed unused editor-only functions causing compiler errors when compiling the game. #rb keli #tests none Change 2860242 on 2016/02/09 by Justin.Sargent Made a number of DialogueWave quality of life improvements to the editor and specifically SoundCue editing. New right-click option on SoundWaves to create a DialogueWave [CL 2863630 by Andrew Grant in Main branch]
2016-02-11 14:39:50 -05:00
ConfigSection.Add( TEXT("SkipGatherCache"), Target->Settings.GatherFromPackages.SkipGatherCache ? TEXT("true") : TEXT("false") );
}
// GatherTextFromMetadata
if (Target->Settings.GatherFromMetaData.IsEnabled)
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GatherTextFromMetadata") );
// Include Paths
for (const auto& IncludePath : Target->Settings.GatherFromMetaData.IncludePathWildcards)
{
ConfigSection.Add( TEXT("IncludePathFilters"), IncludePath.Pattern );
}
// Exclude Paths
for (const auto& ExcludePath : Target->Settings.GatherFromMetaData.ExcludePathWildcards)
{
ConfigSection.Add( TEXT("ExcludePathFilters"), ExcludePath.Pattern );
}
// Package Extensions
for (const FMetaDataKeyGatherSpecification& Specification : Target->Settings.GatherFromMetaData.KeySpecifications)
{
ConfigSection.Add( TEXT("InputKeys"), Specification.MetaDataKey.Name );
ConfigSection.Add( TEXT("OutputNamespaces"), Specification.TextNamespace );
ConfigSection.Add( TEXT("OutputKeys"), FString::Printf(TEXT("\"%s\""), *Specification.TextKeyPattern.Pattern) );
}
ConfigSection.Add( TEXT("ShouldGatherFromEditorOnlyData"), Target->Settings.GatherFromMetaData.ShouldGatherFromEditorOnlyData ? TEXT("true") : TEXT("false") );
}
// GenerateGatherManifest
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GenerateGatherManifest") );
}
// GenerateGatherArchive
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GenerateGatherArchive") );
}
// GenerateTextLocalizationReport
{
FConfigSection& ConfigSection = Script.GatherTextStep(GatherTextStepIndex++);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GenerateTextLocalizationReport") );
ConfigSection.Add( TEXT("bWordCountReport"), TEXT("true") );
ConfigSection.Add( TEXT("WordCountReportName"), FPaths::GetCleanFilename( GetWordCountCSVPath(Target) ) );
ConfigSection.Add( TEXT("bConflictReport"), TEXT("true") );
ConfigSection.Add( TEXT("ConflictReportName"), FPaths::GetCleanFilename( GetConflictReportPath(Target) ) );
}
Script.Dirty = true;
return Script;
}
FString GetGatherScriptPath(const ULocalizationTarget* const Target)
{
return GetScriptDirectory(Target) / FString::Printf( TEXT("%s_Gather.%s"), *(Target->Settings.Name), TEXT("ini") );
}
FLocalizationConfigurationScript GenerateImportScript(const ULocalizationTarget* const Target, const TOptional<FString> CultureName, const TOptional<FString> OutputPathOverride)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// CommonSettings
{
FConfigSection& ConfigSection = Script.CommonSettings();
FString SourcePath;
// Overriding output path changes the source directory for the PO file.
if (OutputPathOverride.IsSet())
{
// The output path for a specific culture is a file path.
if (CultureName.IsSet())
{
SourcePath = MakePathRelativeForCommandletProcess( FPaths::GetPath(OutputPathOverride.GetValue()), !Target->IsMemberOfEngineTargetSet() );
}
// Otherwise, it is a directory path.
else
{
SourcePath = MakePathRelativeForCommandletProcess( OutputPathOverride.GetValue(), !Target->IsMemberOfEngineTargetSet() );
}
}
// Use the default PO file's directory path.
else
{
SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
}
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
if (Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex))
{
ConfigSection.Add( TEXT("NativeCulture"), Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName );
}
const auto& AddCultureToGenerate = [&](const int32 Index)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), Target->Settings.SupportedCulturesStatistics[Index].CultureName );
};
// Import for a specific culture.
if (CultureName.IsSet())
{
ConfigSection.Add( TEXT("CulturesToGenerate"), CultureName.GetValue() );
}
// Import for all cultures.
else
{
for (const FCultureStatistics& CultureStatistics : Target->Settings.SupportedCulturesStatistics)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), CultureStatistics.CultureName );
}
}
// Do not use culture subdirectories if importing a single culture to a specific directory.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
ConfigSection.Add( TEXT("bUseCultureDirectory"), "false" );
}
ConfigSection.Add( TEXT("ManifestName"), FPaths::GetCleanFilename(GetManifestPath(Target)) );
ConfigSection.Add( TEXT("ArchiveName"), FPaths::GetCleanFilename(GetArchivePath(Target, FString())) );
FString POFileName;
// The output path for a specific culture is a file path.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
POFileName = FPaths::GetCleanFilename( OutputPathOverride.GetValue() );
}
// Use the default PO file's name.
else
{
POFileName = FPaths::GetCleanFilename( GetDefaultPOFileName( Target ) );
}
ConfigSection.Add( TEXT("PortableObjectName"), POFileName );
}
// GatherTextStep0 - InternationalizationExport
{
FConfigSection& ConfigSection = Script.GatherTextStep(0);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("InternationalizationExport") );
ConfigSection.Add( TEXT("bImportLoc"), TEXT("true") );
}
Script.Dirty = true;
return Script;
}
FString GetImportScriptPath(const ULocalizationTarget* const Target, const TOptional<FString> CultureName)
{
const FString ConfigFileDirectory = GetScriptDirectory(Target);
FString ConfigFilePath;
if (CultureName.IsSet())
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Import_%s.%s"), *Target->Settings.Name, *CultureName.GetValue(), TEXT("ini") );
}
else
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Import.%s"), *Target->Settings.Name, TEXT("ini") );
}
return ConfigFilePath;
}
FLocalizationConfigurationScript GenerateExportScript(const ULocalizationTarget* const Target, const TOptional<FString> CultureName, const TOptional<FString> OutputPathOverride)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// CommonSettings
{
FConfigSection& ConfigSection = Script.CommonSettings();
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
FString DestinationPath;
// Overriding output path changes the destination directory for the PO file.
if (OutputPathOverride.IsSet())
{
// The output path for a specific culture is a file path.
if (CultureName.IsSet())
{
DestinationPath = MakePathRelativeForCommandletProcess( FPaths::GetPath(OutputPathOverride.GetValue()), !Target->IsMemberOfEngineTargetSet() );
}
// Otherwise, it is a directory path.
else
{
DestinationPath = MakePathRelativeForCommandletProcess( OutputPathOverride.GetValue(), !Target->IsMemberOfEngineTargetSet() );
}
}
// Use the default PO file's directory path.
else
{
DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
}
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
if (Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex))
{
ConfigSection.Add( TEXT("NativeCulture"), Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName );
}
const auto& AddCultureToGenerate = [&](const int32 Index)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), Target->Settings.SupportedCulturesStatistics[Index].CultureName );
};
// Export for a specific culture.
if (CultureName.IsSet())
{
const int32 CultureIndex = Target->Settings.SupportedCulturesStatistics.IndexOfByPredicate([CultureName](const FCultureStatistics& Culture) { return Culture.CultureName == CultureName.GetValue(); });
AddCultureToGenerate(CultureIndex);
}
// Export for all cultures.
else
{
for (int32 CultureIndex = 0; CultureIndex < Target->Settings.SupportedCulturesStatistics.Num(); ++CultureIndex)
{
AddCultureToGenerate(CultureIndex);
}
}
// Do not use culture subdirectories if exporting a single culture to a specific directory.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
ConfigSection.Add( TEXT("bUseCultureDirectory"), "false" );
}
ConfigSection.Add( TEXT("ManifestName"), FPaths::GetCleanFilename(GetManifestPath(Target)) );
ConfigSection.Add( TEXT("ArchiveName"), FPaths::GetCleanFilename(GetArchivePath(Target, FString())) );
FString POFileName;
// The output path for a specific culture is a file path.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
POFileName = FPaths::GetCleanFilename( OutputPathOverride.GetValue() );
}
// Use the default PO file's name.
else
{
POFileName = FPaths::GetCleanFilename( GetDefaultPOPath( Target, CultureName.Get( TEXT("") ) ) );
}
ConfigSection.Add( TEXT("PortableObjectName"), POFileName );
}
// GatherTextStep0 - InternationalizationExport
{
FConfigSection& ConfigSection = Script.GatherTextStep(0);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("InternationalizationExport") );
ConfigSection.Add(TEXT("bExportLoc"), TEXT("true"));
// Export-specific settings.
{
ConfigSection.Add(TEXT("ShouldPersistCommentsOnExport"), Target->Settings.ExportSettings.ShouldPersistCommentsOnExport ? TEXT("true") : TEXT("false"));
ConfigSection.Add(TEXT("ShouldAddSourceLocationsAsComments"), Target->Settings.ExportSettings.ShouldAddSourceLocationsAsComments ? TEXT("true") : TEXT("false"));
}
}
Script.Dirty = true;
return Script;
}
FString GetExportScriptPath(const ULocalizationTarget* const Target, const TOptional<FString> CultureName)
{
const FString ConfigFileDirectory = GetScriptDirectory(Target);
FString ConfigFilePath;
if (CultureName.IsSet())
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Export_%s.%s"), *Target->Settings.Name, *CultureName.GetValue(), TEXT("ini") );
}
else
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Export.%s"), *Target->Settings.Name, TEXT("ini") );
}
return ConfigFilePath;
}
FLocalizationConfigurationScript GenerateWordCountReportScript(const ULocalizationTarget* const Target)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// CommonSettings
{
FConfigSection& ConfigSection = Script.CommonSettings();
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
ConfigSection.Add( TEXT("ManifestName"), FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("manifest") ) );
for (const FCultureStatistics& CultureStatistics : Target->Settings.SupportedCulturesStatistics)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), CultureStatistics.CultureName );
}
}
// GatherTextStep0 - GenerateTextLocalizationReport
{
FConfigSection& ConfigSection = Script.GatherTextStep(0);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GenerateTextLocalizationReport") );
ConfigSection.Add( TEXT("bWordCountReport"), TEXT("true") );
ConfigSection.Add( TEXT("WordCountReportName"), FPaths::GetCleanFilename( GetWordCountCSVPath(Target) ) );
}
Script.Dirty = true;
return Script;
}
FString GetWordCountReportScriptPath(const ULocalizationTarget* const Target)
{
return GetScriptDirectory(Target) / FString::Printf( TEXT("%s_GenerateReports.%s"), *(Target->Settings.Name), TEXT("ini") );
}
FLocalizationConfigurationScript GenerateCompileScript(const ULocalizationTarget* const Target, const TOptional<FString> CultureName)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// CommonSettings
{
FConfigSection& ConfigSection = Script.CommonSettings();
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
ConfigSection.Add( TEXT("ManifestName"), FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("manifest") ) );
ConfigSection.Add( TEXT("ResourceName"), FString::Printf( TEXT("%s.%s"), *Target->Settings.Name, TEXT("locres") ) );
if (Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex))
{
ConfigSection.Add( TEXT("NativeCulture"), Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName );
}
const auto& AddCultureToGenerate = [&](const int32 Index)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), Target->Settings.SupportedCulturesStatistics[Index].CultureName );
};
// Compile a specific culture.
if (CultureName.IsSet())
{
const int32 CultureIndex = Target->Settings.SupportedCulturesStatistics.IndexOfByPredicate([CultureName](const FCultureStatistics& Culture) { return Culture.CultureName == CultureName.GetValue(); });
AddCultureToGenerate(CultureIndex);
}
// Compile all cultures.
else
{
for (int32 CultureIndex = 0; CultureIndex < Target->Settings.SupportedCulturesStatistics.Num(); ++CultureIndex)
{
AddCultureToGenerate(CultureIndex);
}
}
}
// GatherTextStep0 - GenerateTextLocalizationResource
{
FConfigSection& ConfigSection = Script.GatherTextStep(0);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("GenerateTextLocalizationResource") );
}
Script.Dirty = true;
return Script;
}
FString GetCompileScriptPath(const ULocalizationTarget* const Target, const TOptional<FString> CultureName)
{
const FString ConfigFileDirectory = GetScriptDirectory(Target);
FString ConfigFilePath;
if (CultureName.IsSet())
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Compile_%s.%s"), *Target->Settings.Name, *CultureName.GetValue(), TEXT("ini") );
}
else
{
ConfigFilePath = ConfigFileDirectory / FString::Printf( TEXT("%s_Compile.%s"), *Target->Settings.Name, TEXT("ini") );
}
return ConfigFilePath;
}
FLocalizationConfigurationScript GenerateRegenerateResourcesScript(const ULocalizationTarget* const Target)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeForCommandletProcess(GetContentDir(Target), !Target->IsMemberOfEngineTargetSet());
// RegenerateResources
{
FConfigSection& ConfigSection = Script.FindOrAdd("RegenerateResources");;
if (Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex))
{
ConfigSection.Add(TEXT("NativeCulture"), Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName);
}
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add(TEXT("SourcePath"), SourcePath);
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add(TEXT("DestinationPath"), DestinationPath);
ConfigSection.Add(TEXT("ManifestName"), FString::Printf(TEXT("%s.%s"), *Target->Settings.Name, TEXT("manifest")));
ConfigSection.Add(TEXT("ResourceName"), FString::Printf(TEXT("%s.%s"), *Target->Settings.Name, TEXT("locres")));
}
Script.Dirty = true;
return Script;
}
FString GetRegenerateResourcesScriptPath(const ULocalizationTarget* const Target)
{
return GetScriptDirectory(Target) / FString::Printf(TEXT("Regenerate%s.%s"), *(Target->Settings.Name), TEXT("ini"));
}
}