2016-01-07 08:17:16 -05:00
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2015-01-27 16:31:40 -05:00
2015-07-09 19:38:01 -04:00
# include "LocalizationPrivatePCH.h"
2015-01-27 16:31:40 -05:00
# include "LocalizationCommandletTasks.h"
# include "LocalizationCommandletExecution.h"
# include "LocalizationConfigurationScript.h"
2015-01-27 18:24:26 -05:00
# define LOCTEXT_NAMESPACE "LocalizationCommandletTasks"
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : GatherTargets ( const TSharedRef < SWindow > & ParentWindow , const TArray < ULocalizationTarget * > & Targets )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-09 15:38:32 -04:00
for ( ULocalizationTarget * Target : Targets )
2015-01-27 16:31:40 -05:00
{
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText GatherTaskName = FText : : Format ( LOCTEXT ( " GatherTaskNameFormat " , " Gather Text for {TargetName} " ) , Arguments ) ;
2015-03-09 15:38:32 -04:00
const FString GatherScriptPath = LocalizationConfigurationScript : : GetGatherScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateGatherScript ( Target ) . Write ( GatherScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( GatherTaskName , GatherScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
}
2015-01-27 18:24:26 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , LOCTEXT ( " GatherAllTargetsWindowTitle " , " Gather Text for All Targets " ) , Tasks ) ;
2015-01-27 16:31:40 -05:00
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : GatherTarget ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-09 15:38:32 -04:00
const FString GatherScriptPath = LocalizationConfigurationScript : : GetGatherScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateGatherScript ( Target ) . Write ( GatherScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " GatherTaskName " , " Gather Text " ) , GatherScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " GatherTargetWindowTitle " , " Gather Text for Target {TargetName} " ) , Arguments ) ;
2015-01-27 16:31:40 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ImportTargets ( const TSharedRef < SWindow > & ParentWindow , const TArray < ULocalizationTarget * > & Targets , const TOptional < FString > DirectoryPath )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-09 15:38:32 -04:00
for ( ULocalizationTarget * Target : Targets )
2015-01-27 16:31:40 -05:00
{
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText ImportTaskName = FText : : Format ( LOCTEXT ( " ImportTaskNameFormat " , " Import Translations for {TargetName} " ) , Arguments ) ;
2015-03-09 15:38:32 -04:00
const FString ImportScriptPath = LocalizationConfigurationScript : : GetImportScriptPath ( Target , TOptional < FString > ( ) ) ;
const TOptional < FString > DirectoryPathForTarget = DirectoryPath . IsSet ( ) ? DirectoryPath . GetValue ( ) / Target - > Settings . Name : TOptional < FString > ( ) ;
LocalizationConfigurationScript : : GenerateImportScript ( Target , TOptional < FString > ( ) , DirectoryPathForTarget ) . Write ( ImportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( ImportTaskName , ImportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText ReportTaskName = FText : : Format ( LOCTEXT ( " ReportTaskNameFormat " , " Generate Reports for {TargetName} " ) , Arguments ) ;
2015-03-18 19:14:43 -04:00
const FString ReportScriptPath = LocalizationConfigurationScript : : GetWordCountReportScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateWordCountReportScript ( Target ) . Write ( ReportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( ReportTaskName , ReportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
}
2015-01-27 18:24:26 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , LOCTEXT ( " ImportForAllTargetsWindowTitle " , " Import Translations for All Targets " ) , Tasks ) ;
2015-01-27 16:31:40 -05:00
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ImportTarget ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target , const TOptional < FString > DirectoryPath )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-09 15:38:32 -04:00
const FString ImportScriptPath = LocalizationConfigurationScript : : GetImportScriptPath ( Target , TOptional < FString > ( ) ) ;
LocalizationConfigurationScript : : GenerateImportScript ( Target , TOptional < FString > ( ) , DirectoryPath ) . Write ( ImportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ImportTaskName " , " Import Translations " ) , ImportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
2015-03-18 19:14:43 -04:00
const FString ReportScriptPath = LocalizationConfigurationScript : : GetWordCountReportScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateWordCountReportScript ( Target ) . Write ( ReportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ReportTaskName " , " Generate Reports " ) , ReportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " ImportForTargetWindowTitle " , " Import Translations for Target {TargetName} " ) , Arguments ) ;
2015-01-27 16:31:40 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ImportCulture ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target , const FString & CultureName , const TOptional < FString > FilePath )
2015-01-27 16:31:40 -05:00
{
FCulturePtr Culture = FInternationalization : : Get ( ) . GetCulture ( CultureName ) ;
if ( ! Culture . IsValid ( ) )
{
return false ;
}
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-09 15:38:32 -04:00
const FString DefaultImportScriptPath = LocalizationConfigurationScript : : GetImportScriptPath ( Target , TOptional < FString > ( CultureName ) ) ;
2015-01-30 16:29:01 -05:00
const FString ImportScriptPath = FPaths : : CreateTempFilename ( * FPaths : : GetPath ( DefaultImportScriptPath ) , * FPaths : : GetBaseFilename ( DefaultImportScriptPath ) , * FPaths : : GetExtension ( DefaultImportScriptPath , true ) ) ;
2015-03-09 15:38:32 -04:00
LocalizationConfigurationScript : : GenerateImportScript ( Target , TOptional < FString > ( CultureName ) , FilePath ) . Write ( ImportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ImportTaskName " , " Import Translations " ) , ImportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
2015-03-18 19:14:43 -04:00
const FString ReportScriptPath = LocalizationConfigurationScript : : GetWordCountReportScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateWordCountReportScript ( Target ) . Write ( ReportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ReportTaskName " , " Generate Reports " ) , ReportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " ImportCultureForTargetWindowTitle " , " Import {CultureName} Translations for Target {TargetName} " ) , Arguments ) ;
2015-01-30 16:29:01 -05:00
bool HasSucceeeded = LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
IFileManager : : Get ( ) . Delete ( * ImportScriptPath ) ; // Don't clutter up the loc config directory with scripts for individual cultures.
return HasSucceeeded ;
2015-01-27 16:31:40 -05:00
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ExportTargets ( const TSharedRef < SWindow > & ParentWindow , const TArray < ULocalizationTarget * > & Targets , const TOptional < FString > DirectoryPath )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-09 15:38:32 -04:00
for ( ULocalizationTarget * Target : Targets )
2015-01-27 16:31:40 -05:00
{
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText ExportTaskName = FText : : Format ( LOCTEXT ( " ExportTaskNameFormat " , " Export Translations for {TargetName} " ) , Arguments ) ;
2015-03-09 15:38:32 -04:00
const FString ExportScriptPath = LocalizationConfigurationScript : : GetExportScriptPath ( Target , TOptional < FString > ( ) ) ;
const TOptional < FString > DirectoryPathForTarget = DirectoryPath . IsSet ( ) ? DirectoryPath . GetValue ( ) / Target - > Settings . Name : TOptional < FString > ( ) ;
LocalizationConfigurationScript : : GenerateExportScript ( Target , TOptional < FString > ( ) , DirectoryPathForTarget ) . Write ( ExportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( ExportTaskName , ExportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
}
2015-01-27 18:24:26 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , LOCTEXT ( " ExportForAllTargetsWindowTitle " , " Export Translations for All Targets " ) , Tasks ) ;
2015-01-27 16:31:40 -05:00
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ExportTarget ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target , const TOptional < FString > DirectoryPath )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-09 15:38:32 -04:00
const FString ExportScriptPath = LocalizationConfigurationScript : : GetExportScriptPath ( Target , TOptional < FString > ( ) ) ;
LocalizationConfigurationScript : : GenerateExportScript ( Target , TOptional < FString > ( ) , DirectoryPath ) . Write ( ExportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ExportTaskName " , " Export Translations " ) , ExportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " ExportForTargetWindowTitle " , " Export Translations for Target {TargetName} " ) , Arguments ) ;
2015-01-27 16:31:40 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : ExportCulture ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target , const FString & CultureName , const TOptional < FString > FilePath )
2015-01-27 16:31:40 -05:00
{
FCulturePtr Culture = FInternationalization : : Get ( ) . GetCulture ( CultureName ) ;
if ( ! Culture . IsValid ( ) )
{
return false ;
}
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-09 15:38:32 -04:00
const FString DefaultExportScriptPath = LocalizationConfigurationScript : : GetExportScriptPath ( Target , TOptional < FString > ( CultureName ) ) ;
2015-01-30 16:29:01 -05:00
const FString ExportScriptPath = FPaths : : CreateTempFilename ( * FPaths : : GetPath ( DefaultExportScriptPath ) , * FPaths : : GetBaseFilename ( DefaultExportScriptPath ) , * FPaths : : GetExtension ( DefaultExportScriptPath , true ) ) ;
2015-03-09 15:38:32 -04:00
LocalizationConfigurationScript : : GenerateExportScript ( Target , TOptional < FString > ( CultureName ) , FilePath ) . Write ( ExportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ExportTaskName " , " Export Translations " ) , ExportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-01-27 18:24:26 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " ExportCultureForTargetWindowTitle " , " Export {CultureName} Translations for Target {TargetName} " ) , Arguments ) ;
2015-01-30 16:29:01 -05:00
bool HasSucceeeded = LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
IFileManager : : Get ( ) . Delete ( * ExportScriptPath ) ; // Don't clutter up the loc config directory with scripts for individual cultures.
return HasSucceeeded ;
2015-01-27 16:31:40 -05:00
}
2015-03-18 19:14:43 -04:00
bool LocalizationCommandletTasks : : GenerateWordCountReportsForTargets ( const TSharedRef < SWindow > & ParentWindow , const TArray < ULocalizationTarget * > & Targets )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-09 15:38:32 -04:00
for ( ULocalizationTarget * Target : Targets )
2015-01-27 16:31:40 -05:00
{
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-03-18 19:14:43 -04:00
const FText ReportTaskName = FText : : Format ( LOCTEXT ( " ReportTaskNameFormat " , " Generate Word Count Report for {TargetName} " ) , Arguments ) ;
const FString ReportScriptPath = LocalizationConfigurationScript : : GetWordCountReportScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateWordCountReportScript ( Target ) . Write ( ReportScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( ReportTaskName , ReportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
}
2015-03-18 19:14:43 -04:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , LOCTEXT ( " GenerateReportsForAllTargetsWindowTitle " , " Generate Word Count Reports for All Targets " ) , Tasks ) ;
2015-01-27 16:31:40 -05:00
}
2015-03-18 19:14:43 -04:00
bool LocalizationCommandletTasks : : GenerateWordCountReportForTarget ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target )
2015-01-27 16:31:40 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-27 16:31:40 -05:00
2015-03-18 19:14:43 -04:00
const FString ReportScriptPath = LocalizationConfigurationScript : : GetWordCountReportScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateWordCountReportScript ( Target ) . Write ( ReportScriptPath ) ;
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " ReportTaskName " , " Generate Word Count Report " ) , ReportScriptPath , ShouldUseProjectFile ) ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-27 16:31:40 -05:00
2015-03-18 19:14:43 -04:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " GenerateReportForTargetWindowTitle " , " Generate Word Count Report for Target {TargetName} " ) , Arguments ) ;
2015-01-27 16:31:40 -05:00
return LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
2015-01-27 18:24:26 -05:00
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : CompileTargets ( const TSharedRef < SWindow > & ParentWindow , const TArray < ULocalizationTarget * > & Targets )
2015-01-30 17:29:25 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-09 15:38:32 -04:00
for ( ULocalizationTarget * Target : Targets )
2015-01-30 17:29:25 -05:00
{
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-30 17:29:25 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-30 17:29:25 -05:00
const FText CompileTaskName = FText : : Format ( LOCTEXT ( " CompileTaskNameFormat " , " Compile Translations for {TargetName} " ) , Arguments ) ;
2015-03-09 15:38:32 -04:00
const FString CompileScriptPath = LocalizationConfigurationScript : : GetCompileScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateCompileScript ( Target ) . Write ( CompileScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( CompileTaskName , CompileScriptPath , ShouldUseProjectFile ) ) ;
2015-01-30 17:29:25 -05:00
}
return LocalizationCommandletExecution : : Execute ( ParentWindow , LOCTEXT ( " GenerateLocResForAllTargetsWindowTitle " , " Compile Translations for All Targets " ) , Tasks ) ;
}
2015-03-09 15:38:32 -04:00
bool LocalizationCommandletTasks : : CompileTarget ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target )
2015-01-30 17:29:25 -05:00
{
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
2015-03-12 19:41:56 -04:00
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
2015-01-30 17:29:25 -05:00
2015-03-09 15:38:32 -04:00
const FString CompileScriptPath = LocalizationConfigurationScript : : GetCompileScriptPath ( Target ) ;
LocalizationConfigurationScript : : GenerateCompileScript ( Target ) . Write ( CompileScriptPath ) ;
2015-03-12 19:41:56 -04:00
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " CompileTaskName " , " Compile Translations " ) , CompileScriptPath , ShouldUseProjectFile ) ) ;
2015-01-30 17:29:25 -05:00
FFormatNamedArguments Arguments ;
2015-03-09 15:38:32 -04:00
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
2015-01-30 17:29:25 -05:00
const FText WindowTitle = FText : : Format ( LOCTEXT ( " GenerateLocResForTargetWindowTitle " , " Compile Translations for Target {TargetName} " ) , Arguments ) ;
return LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
}
2015-05-21 22:15:36 -04:00
bool LocalizationCommandletTasks : : CompileCulture ( const TSharedRef < SWindow > & ParentWindow , ULocalizationTarget * const Target , const FString & CultureName )
{
FCulturePtr Culture = FInternationalization : : Get ( ) . GetCulture ( CultureName ) ;
if ( ! Culture . IsValid ( ) )
{
return false ;
}
TArray < LocalizationCommandletExecution : : FTask > Tasks ;
const bool ShouldUseProjectFile = ! Target - > IsMemberOfEngineTargetSet ( ) ;
const FString DefaultCompileScriptPath = LocalizationConfigurationScript : : GetCompileScriptPath ( Target , TOptional < FString > ( CultureName ) ) ;
const FString CompileScriptPath = FPaths : : CreateTempFilename ( * FPaths : : GetPath ( DefaultCompileScriptPath ) , * FPaths : : GetBaseFilename ( DefaultCompileScriptPath ) , * FPaths : : GetExtension ( DefaultCompileScriptPath , true ) ) ;
LocalizationConfigurationScript : : GenerateCompileScript ( Target , TOptional < FString > ( CultureName ) ) . Write ( CompileScriptPath ) ;
Tasks . Add ( LocalizationCommandletExecution : : FTask ( LOCTEXT ( " CompileTaskName " , " Compile Translations " ) , CompileScriptPath , ShouldUseProjectFile ) ) ;
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
Arguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( Target - > Settings . Name ) ) ;
const FText WindowTitle = FText : : Format ( LOCTEXT ( " CompileCultureForTargetWindowTitle " , " Compile {CultureName} Translations for Target {TargetName} " ) , Arguments ) ;
bool HasSucceeeded = LocalizationCommandletExecution : : Execute ( ParentWindow , WindowTitle , Tasks ) ;
IFileManager : : Get ( ) . Delete ( * CompileScriptPath ) ; // Don't clutter up the loc config directory with scripts for individual cultures.
return HasSucceeeded ;
}
2015-01-27 18:24:26 -05:00
# undef LOCTEXT_NAMESPACE