2015-03-09 15:09:46 -04:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2015-01-27 16:31:40 -05:00
# include "LocalizationDashboardPrivatePCH.h"
# include "SLocalizationTargetEditorCultureRow.h"
# include "ITranslationEditor.h"
# include "LocalizationConfigurationScript.h"
# include "LocalizationCommandletTasks.h"
2015-01-27 18:24:26 -05:00
# define LOCTEXT_NAMESPACE "LocalizationTargetEditorCultureRow"
2015-01-27 16:31:40 -05:00
void SLocalizationTargetEditorCultureRow : : Construct ( const FTableRowArgs & InArgs , const TSharedRef < STableViewBase > & OwnerTableView , const TSharedRef < IPropertyUtilities > & InPropertyUtilities , const TSharedRef < IPropertyHandle > & InTargetSettingsPropertyHandle , const int32 InCultureIndex )
{
PropertyUtilities = InPropertyUtilities ;
TargetSettingsPropertyHandle = InTargetSettingsPropertyHandle ;
CultureIndex = InCultureIndex ;
FSuperRowType : : Construct ( InArgs , OwnerTableView ) ;
}
TSharedRef < SWidget > SLocalizationTargetEditorCultureRow : : GenerateWidgetForColumn ( const FName & ColumnName )
{
TSharedPtr < SWidget > Return ;
2015-04-22 16:39:20 -04:00
if ( ColumnName = = " IsNative " )
{
Return = SNew ( SCheckBox )
. Style ( & FCoreStyle : : Get ( ) . GetWidgetStyle < FCheckBoxStyle > ( " RadioButton " ) )
. IsChecked_Lambda ( [ this ] ( ) { return IsNativeCultureForTarget ( ) ? ECheckBoxState : : Checked : ECheckBoxState : : Unchecked ; } )
. OnCheckStateChanged ( this , & SLocalizationTargetEditorCultureRow : : OnNativeCultureCheckStateChanged ) ;
}
else if ( ColumnName = = " Culture " )
2015-01-27 16:31:40 -05:00
{
// Culture Name
2015-04-22 16:39:20 -04:00
Return = SNew ( STextBlock )
. Text ( this , & SLocalizationTargetEditorCultureRow : : GetCultureDisplayName )
. ToolTipText ( this , & SLocalizationTargetEditorCultureRow : : GetCultureName ) ;
2015-01-27 16:31:40 -05:00
}
else if ( ColumnName = = " WordCount " )
{
// Progress Bar and Word Counts
Return = SNew ( SOverlay )
+ SOverlay : : Slot ( )
. VAlign ( VAlign_Fill )
. Padding ( 0.0f )
[
SNew ( SProgressBar )
. Percent ( this , & SLocalizationTargetEditorCultureRow : : GetProgressPercentage )
]
+ SOverlay : : Slot ( )
. HAlign ( HAlign_Center )
. VAlign ( VAlign_Center )
. Padding ( 2.0f )
[
SNew ( STextBlock )
. Text ( this , & SLocalizationTargetEditorCultureRow : : GetWordCountText )
] ;
}
else if ( ColumnName = = " Actions " )
{
TSharedRef < SHorizontalBox > HorizontalBox = SNew ( SHorizontalBox ) ;
Return = HorizontalBox ;
// Edit
HorizontalBox - > AddSlot ( )
. FillWidth ( 1.0f )
. HAlign ( HAlign_Center )
. VAlign ( VAlign_Center )
[
SNew ( SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , TEXT ( " HoverHintOnly " ) )
2015-01-27 18:24:26 -05:00
. ToolTipText ( LOCTEXT ( " EditButtonLabel " , " Edit Translations " ) )
2015-01-27 16:31:40 -05:00
. OnClicked ( this , & SLocalizationTargetEditorCultureRow : : Edit )
. Content ( )
[
SNew ( SImage )
. Image ( FEditorStyle : : GetBrush ( " LocalizationTargetEditor.EditTranslations " ) )
]
] ;
// Import
HorizontalBox - > AddSlot ( )
. FillWidth ( 1.0f )
. HAlign ( HAlign_Center )
. VAlign ( VAlign_Center )
[
SNew ( SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , TEXT ( " HoverHintOnly " ) )
2015-01-27 18:24:26 -05:00
. ToolTipText ( LOCTEXT ( " ImportButtonLabel " , " Import " ) )
2015-01-27 16:31:40 -05:00
. OnClicked ( this , & SLocalizationTargetEditorCultureRow : : Import )
. Content ( )
[
SNew ( SImage )
. Image ( FEditorStyle : : GetBrush ( " LocalizationTargetEditor.ImportForCulture " ) )
]
] ;
// Export
HorizontalBox - > AddSlot ( )
. FillWidth ( 1.0f )
. HAlign ( HAlign_Center )
. VAlign ( VAlign_Center )
[
SNew ( SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , TEXT ( " HoverHintOnly " ) )
. ToolTipText ( NSLOCTEXT ( " LocalizationTargetCultureActions " , " ExportButtonLabel " , " Export " ) )
. OnClicked ( this , & SLocalizationTargetEditorCultureRow : : Export )
. Content ( )
[
SNew ( SImage )
. Image ( FEditorStyle : : GetBrush ( " LocalizationTargetEditor.ExportForCulture " ) )
]
] ;
// Delete Culture
HorizontalBox - > AddSlot ( )
. FillWidth ( 1.0f )
. HAlign ( HAlign_Center )
. VAlign ( VAlign_Center )
[
SNew ( SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , TEXT ( " HoverHintOnly " ) )
. ToolTipText ( NSLOCTEXT ( " LocalizationTargetActions " , " DeleteButtonLabel " , " Delete " ) )
. IsEnabled ( this , & SLocalizationTargetEditorCultureRow : : CanDelete )
. OnClicked ( this , & SLocalizationTargetEditorCultureRow : : EnqueueDeletion )
. Content ( )
[
SNew ( SImage )
. Image ( FEditorStyle : : GetBrush ( " LocalizationTargetEditor.DeleteCulture " ) )
]
] ;
}
return Return . IsValid ( ) ? Return . ToSharedRef ( ) : SNullWidget : : NullWidget ;
}
2015-03-09 15:09:46 -04:00
ULocalizationTarget * SLocalizationTargetEditorCultureRow : : GetTarget ( ) const
{
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
TArray < UObject * > OuterObjects ;
TargetSettingsPropertyHandle - > GetOuterObjects ( OuterObjects ) ;
return CastChecked < ULocalizationTarget > ( OuterObjects . Top ( ) ) ;
}
return nullptr ;
}
2015-01-27 16:31:40 -05:00
FLocalizationTargetSettings * SLocalizationTargetEditorCultureRow : : GetTargetSettings ( ) const
{
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
TArray < void * > RawData ;
TargetSettingsPropertyHandle - > AccessRawData ( RawData ) ;
return RawData . Num ( ) ? reinterpret_cast < FLocalizationTargetSettings * > ( RawData . Top ( ) ) : nullptr ;
}
return nullptr ;
}
FCultureStatistics * SLocalizationTargetEditorCultureRow : : GetCultureStatistics ( ) const
{
FLocalizationTargetSettings * const TargetSettings = GetTargetSettings ( ) ;
if ( TargetSettings )
{
2015-04-22 16:39:20 -04:00
return & TargetSettings - > SupportedCulturesStatistics [ CultureIndex ] ;
2015-01-27 16:31:40 -05:00
}
return nullptr ;
}
FCulturePtr SLocalizationTargetEditorCultureRow : : GetCulture ( ) const
{
FCultureStatistics * const CultureStatistics = GetCultureStatistics ( ) ;
if ( CultureStatistics )
{
return FInternationalization : : Get ( ) . GetCulture ( CultureStatistics - > CultureName ) ;
}
return nullptr ;
}
bool SLocalizationTargetEditorCultureRow : : IsNativeCultureForTarget ( ) const
{
FLocalizationTargetSettings * const TargetSettings = GetTargetSettings ( ) ;
2015-04-22 16:39:20 -04:00
return TargetSettings - > SupportedCulturesStatistics . IsValidIndex ( TargetSettings - > NativeCultureIndex ) & & & ( TargetSettings - > SupportedCulturesStatistics [ TargetSettings - > NativeCultureIndex ] ) = = GetCultureStatistics ( ) ;
}
void SLocalizationTargetEditorCultureRow : : OnNativeCultureCheckStateChanged ( const ECheckBoxState CheckState )
{
FLocalizationTargetSettings * const TargetSettings = GetTargetSettings ( ) ;
if ( TargetSettings & & TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) & & CheckState = = ECheckBoxState : : Checked )
{
const FText FormatPattern = LOCTEXT ( " ChangingNativeCultureWarningMessage " , " This action can not be undone and all translations be permanently lost. Are you sure you would like to set the native culture to {CultureName}? " ) ;
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CultureName " ) , GetCultureDisplayName ( ) ) ;
const FText MessageText = FText : : Format ( FormatPattern , Arguments ) ;
const FText TitleText = LOCTEXT ( " ChangingNativeCultureWarningDialogTitle " , " Change Native Culture " ) ;
switch ( FMessageDialog : : Open ( EAppMsgType : : YesNo , MessageText , & TitleText ) )
{
case EAppReturnType : : Yes :
{
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
if ( LocalizationTarget )
{
// Delete data files.
const FString DataDirectory = LocalizationConfigurationScript : : GetDataDirectory ( LocalizationTarget ) ;
IFileManager : : Get ( ) . DeleteDirectory ( * DataDirectory , false , true ) ;
}
UpdateTargetFromReports ( ) ;
TargetSettingsPropertyHandle - > NotifyPreChange ( ) ;
TargetSettings - > NativeCultureIndex = CultureIndex ;
TargetSettingsPropertyHandle - > NotifyPostChange ( ) ;
}
break ;
}
}
2015-01-27 16:31:40 -05:00
}
uint32 SLocalizationTargetEditorCultureRow : : GetWordCount ( ) const
{
FCultureStatistics * const CultureStatistics = GetCultureStatistics ( ) ;
if ( CultureStatistics )
{
return CultureStatistics - > WordCount ;
}
return 0 ;
}
uint32 SLocalizationTargetEditorCultureRow : : GetNativeWordCount ( ) const
{
FLocalizationTargetSettings * const TargetSettings = GetTargetSettings ( ) ;
2015-04-22 16:39:20 -04:00
return TargetSettings & & TargetSettings - > SupportedCulturesStatistics . IsValidIndex ( TargetSettings - > NativeCultureIndex ) ? TargetSettings - > SupportedCulturesStatistics [ TargetSettings - > NativeCultureIndex ] . WordCount : 0 ;
2015-01-27 16:31:40 -05:00
}
FText SLocalizationTargetEditorCultureRow : : GetCultureDisplayName ( ) const
{
const FCulturePtr Culture = GetCulture ( ) ;
return Culture . IsValid ( ) ? FText : : FromString ( Culture - > GetDisplayName ( ) ) : FText : : GetEmpty ( ) ;
}
FText SLocalizationTargetEditorCultureRow : : GetCultureName ( ) const
{
const FCulturePtr Culture = GetCulture ( ) ;
return Culture . IsValid ( ) ? FText : : FromString ( Culture - > GetName ( ) ) : FText : : GetEmpty ( ) ;
}
FText SLocalizationTargetEditorCultureRow : : GetWordCountText ( ) const
{
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " TranslatedWordCount " ) , FText : : AsNumber ( GetWordCount ( ) ) ) ;
TOptional < float > Percentage = GetProgressPercentage ( ) ;
Arguments . Add ( TEXT ( " TranslatedPercentage " ) , FText : : AsPercent ( Percentage . IsSet ( ) ? Percentage . GetValue ( ) : 0.0f ) ) ;
2015-01-27 18:24:26 -05:00
return FText : : Format ( LOCTEXT ( " CultureWordCountProgressFormat " , " {TranslatedWordCount} ({TranslatedPercentage}) " ) , Arguments ) ;
2015-01-27 16:31:40 -05:00
}
TOptional < float > SLocalizationTargetEditorCultureRow : : GetProgressPercentage ( ) const
{
uint32 WordCount = GetWordCount ( ) ;
uint32 NativeWordCount = GetNativeWordCount ( ) ;
return IsNativeCultureForTarget ( ) ? 1.0f : NativeWordCount ! = 0 ? float ( WordCount ) / float ( NativeWordCount ) : 0.0f ;
}
void SLocalizationTargetEditorCultureRow : : UpdateTargetFromReports ( )
{
2015-03-09 15:09:46 -04:00
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
if ( LocalizationTarget )
2015-01-27 16:31:40 -05:00
{
TArray < TSharedPtr < IPropertyHandle > > WordCountPropertyHandles ;
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
const TSharedPtr < IPropertyHandle > SupportedCulturesStatisticsPropertyHandle = TargetSettingsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , SupportedCulturesStatistics ) ) ;
if ( SupportedCulturesStatisticsPropertyHandle . IsValid ( ) & & SupportedCulturesStatisticsPropertyHandle - > IsValidHandle ( ) )
{
uint32 SupportedCultureCount = 0 ;
SupportedCulturesStatisticsPropertyHandle - > GetNumChildren ( SupportedCultureCount ) ;
for ( uint32 i = 0 ; i < SupportedCultureCount ; + + i )
{
const TSharedPtr < IPropertyHandle > ElementPropertyHandle = SupportedCulturesStatisticsPropertyHandle - > GetChildHandle ( i ) ;
if ( ElementPropertyHandle . IsValid ( ) & & ElementPropertyHandle - > IsValidHandle ( ) )
{
const TSharedPtr < IPropertyHandle > WordCountPropertyHandle = SupportedCulturesStatisticsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , WordCount ) ) ;
if ( WordCountPropertyHandle . IsValid ( ) & & WordCountPropertyHandle - > IsValidHandle ( ) )
{
WordCountPropertyHandles . Add ( WordCountPropertyHandle ) ;
}
}
}
}
}
for ( const TSharedPtr < IPropertyHandle > & WordCountPropertyHandle : WordCountPropertyHandles )
{
WordCountPropertyHandle - > NotifyPreChange ( ) ;
}
2015-03-09 15:09:46 -04:00
LocalizationTarget - > UpdateWordCountsFromCSV ( ) ;
LocalizationTarget - > UpdateStatusFromConflictReport ( ) ;
2015-01-27 16:31:40 -05:00
for ( const TSharedPtr < IPropertyHandle > & WordCountPropertyHandle : WordCountPropertyHandles )
{
WordCountPropertyHandle - > NotifyPostChange ( ) ;
}
}
}
FReply SLocalizationTargetEditorCultureRow : : Edit ( )
{
const FCulturePtr Culture = GetCulture ( ) ;
2015-03-09 15:38:32 -04:00
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
if ( Culture . IsValid ( ) & & LocalizationTarget )
2015-01-27 16:31:40 -05:00
{
2015-03-09 15:38:32 -04:00
FModuleManager : : LoadModuleChecked < ITranslationEditor > ( " TranslationEditor " ) . OpenTranslationEditor ( LocalizationConfigurationScript : : GetManifestPath ( LocalizationTarget ) , LocalizationConfigurationScript : : GetArchivePath ( LocalizationTarget , Culture - > GetName ( ) ) ) ;
2015-01-27 16:31:40 -05:00
}
return FReply : : Handled ( ) ;
}
FReply SLocalizationTargetEditorCultureRow : : Import ( )
{
2015-01-30 16:29:01 -05:00
const FCulturePtr Culture = GetCulture ( ) ;
2015-03-09 15:38:32 -04:00
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
2015-01-30 16:29:01 -05:00
IDesktopPlatform * DesktopPlatform = FDesktopPlatformModule : : Get ( ) ;
2015-03-09 15:38:32 -04:00
if ( Culture . IsValid ( ) & & LocalizationTarget & & DesktopPlatform )
2015-01-27 16:31:40 -05:00
{
2015-01-30 16:29:01 -05:00
void * ParentWindowWindowHandle = NULL ;
{
2015-03-06 15:13:38 -05:00
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( AsShared ( ) ) ;
if ( ParentWindow . IsValid ( ) & & ParentWindow - > GetNativeWindow ( ) . IsValid ( ) )
{
ParentWindowWindowHandle = ParentWindow - > GetNativeWindow ( ) - > GetOSWindowHandle ( ) ;
}
2015-01-30 16:29:01 -05:00
}
2015-03-09 15:38:32 -04:00
const FString POFileName = LocalizationConfigurationScript : : GetDefaultPOFileName ( LocalizationTarget ) ;
2015-01-30 16:29:01 -05:00
const FString POFileTypeDescription = LOCTEXT ( " PortableObjectFileDescription " , " Portable Object " ) . ToString ( ) ;
const FString POFileExtension = FPaths : : GetExtension ( POFileName ) ;
const FString POFileExtensionWildcard = FString : : Printf ( TEXT ( " *.%s " ) , * POFileExtension ) ;
const FString FileTypes = FString : : Printf ( TEXT ( " %s (%s)|%s " ) , * POFileTypeDescription , * POFileExtensionWildcard , * POFileExtensionWildcard ) ;
const FString DefaultFilename = POFileName ;
2015-03-09 15:38:32 -04:00
const FString DefaultPath = FPaths : : GetPath ( LocalizationConfigurationScript : : GetDefaultPOPath ( LocalizationTarget , Culture - > GetName ( ) ) ) ;
2015-01-30 16:29:01 -05:00
FText DialogTitle ;
{
FFormatNamedArguments FormatArguments ;
2015-03-09 15:38:32 -04:00
FormatArguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( LocalizationTarget - > Settings . Name ) ) ;
2015-01-30 16:29:01 -05:00
FormatArguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
2015-03-06 15:13:38 -05:00
DialogTitle = FText : : Format ( LOCTEXT ( " ImportSpecificTranslationsForTargetDialogTitleFormat " , " Import {CultureName} Translations for {TargetName} from Directory " ) , FormatArguments ) ;
2015-01-30 16:29:01 -05:00
}
// Prompt the user for the directory
TArray < FString > OpenFilenames ;
if ( DesktopPlatform - > OpenFileDialog ( ParentWindowWindowHandle , DialogTitle . ToString ( ) , DefaultPath , DefaultFilename , FileTypes , 0 , OpenFilenames ) )
2015-01-27 16:31:40 -05:00
{
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( AsShared ( ) ) ;
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : ImportCulture ( ParentWindow . ToSharedRef ( ) , LocalizationTarget , Culture - > GetName ( ) , TOptional < FString > ( OpenFilenames . Top ( ) ) ) ;
2015-01-27 16:31:40 -05:00
UpdateTargetFromReports ( ) ;
}
}
return FReply : : Handled ( ) ;
}
FReply SLocalizationTargetEditorCultureRow : : Export ( )
{
const FCulturePtr Culture = GetCulture ( ) ;
2015-03-09 15:38:32 -04:00
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
2015-01-30 16:29:01 -05:00
IDesktopPlatform * DesktopPlatform = FDesktopPlatformModule : : Get ( ) ;
2015-03-09 15:38:32 -04:00
if ( Culture . IsValid ( ) & & LocalizationTarget & & DesktopPlatform )
2015-01-27 16:31:40 -05:00
{
2015-01-30 16:29:01 -05:00
void * ParentWindowWindowHandle = NULL ;
2015-01-27 16:31:40 -05:00
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( AsShared ( ) ) ;
2015-01-30 16:29:01 -05:00
if ( ParentWindow . IsValid ( ) & & ParentWindow - > GetNativeWindow ( ) . IsValid ( ) )
{
ParentWindowWindowHandle = ParentWindow - > GetNativeWindow ( ) - > GetOSWindowHandle ( ) ;
}
2015-03-09 15:38:32 -04:00
const FString POFileName = LocalizationConfigurationScript : : GetDefaultPOFileName ( LocalizationTarget ) ;
2015-01-30 16:29:01 -05:00
const FString POFileTypeDescription = LOCTEXT ( " PortableObjectFileDescription " , " Portable Object " ) . ToString ( ) ;
const FString POFileExtension = FPaths : : GetExtension ( POFileName ) ;
const FString POFileExtensionWildcard = FString : : Printf ( TEXT ( " *.%s " ) , * POFileExtension ) ;
const FString FileTypes = FString : : Printf ( TEXT ( " %s (%s)|%s " ) , * POFileTypeDescription , * POFileExtensionWildcard , * POFileExtensionWildcard ) ;
const FString DefaultFilename = POFileName ;
2015-03-09 15:38:32 -04:00
const FString DefaultPath = FPaths : : GetPath ( LocalizationConfigurationScript : : GetDefaultPOPath ( LocalizationTarget , Culture - > GetName ( ) ) ) ;
2015-01-30 16:29:01 -05:00
FText DialogTitle ;
{
FFormatNamedArguments FormatArguments ;
2015-03-09 15:38:32 -04:00
FormatArguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( LocalizationTarget - > Settings . Name ) ) ;
2015-01-30 16:29:01 -05:00
FormatArguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
DialogTitle = FText : : Format ( LOCTEXT ( " ExportSpecificTranslationsForTargetDialogTitleFormat " , " Export {CultureName} Translations for {TargetName} to Directory " ) , FormatArguments ) ;
}
// Prompt the user for the directory
TArray < FString > SaveFilenames ;
if ( DesktopPlatform - > SaveFileDialog ( ParentWindowWindowHandle , DialogTitle . ToString ( ) , DefaultPath , DefaultFilename , FileTypes , 0 , SaveFilenames ) )
{
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : ExportCulture ( ParentWindow . ToSharedRef ( ) , LocalizationTarget , Culture - > GetName ( ) , TOptional < FString > ( SaveFilenames . Top ( ) ) ) ;
2015-01-30 16:29:01 -05:00
}
2015-01-27 16:31:40 -05:00
}
return FReply : : Handled ( ) ;
}
bool SLocalizationTargetEditorCultureRow : : CanDelete ( ) const
{
return ! IsNativeCultureForTarget ( ) ;
}
FReply SLocalizationTargetEditorCultureRow : : EnqueueDeletion ( )
{
PropertyUtilities - > EnqueueDeferredAction ( FSimpleDelegate : : CreateSP ( this , & SLocalizationTargetEditorCultureRow : : Delete ) ) ;
return FReply : : Handled ( ) ;
}
void SLocalizationTargetEditorCultureRow : : Delete ( )
{
static bool IsExecuting = false ;
if ( ! IsExecuting )
{
TGuardValue < bool > ReentranceGuard ( IsExecuting , true ) ;
const FCulturePtr Culture = GetCulture ( ) ;
2015-03-09 15:09:46 -04:00
ULocalizationTarget * const LocalizationTarget = GetTarget ( ) ;
if ( Culture . IsValid ( ) & & LocalizationTarget )
2015-01-27 16:31:40 -05:00
{
FText TitleText ;
FText MessageText ;
// Setup dialog for deleting supported culture.
2015-01-27 18:24:26 -05:00
const FText FormatPattern = LOCTEXT ( " DeleteCultureConfirmationDialogMessage " , " This action can not be undone and data will be permanently lost. Are you sure you would like to delete {CultureName}? " ) ;
2015-01-27 16:31:40 -05:00
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CultureName " ) , FText : : FromString ( Culture - > GetDisplayName ( ) ) ) ;
MessageText = FText : : Format ( FormatPattern , Arguments ) ;
2015-01-27 18:24:26 -05:00
TitleText = LOCTEXT ( " DeleteCultureConfirmationDialogTitle " , " Confirm Culture Deletion " ) ;
2015-01-27 16:31:40 -05:00
switch ( FMessageDialog : : Open ( EAppMsgType : : OkCancel , MessageText , & TitleText ) )
{
case EAppReturnType : : Ok :
{
const FString CultureName = Culture - > GetName ( ) ;
2015-03-09 15:09:46 -04:00
LocalizationTarget - > DeleteFiles ( & CultureName ) ;
2015-01-27 16:31:40 -05:00
// Remove this element from the parent array.
const TSharedPtr < IPropertyHandle > SupportedCulturesStatisticsPropertyHandle = TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) ? TargetSettingsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , SupportedCulturesStatistics ) ) : nullptr ;
if ( SupportedCulturesStatisticsPropertyHandle . IsValid ( ) & & SupportedCulturesStatisticsPropertyHandle - > IsValidHandle ( ) )
{
const TSharedPtr < IPropertyHandleArray > ArrayPropertyHandle = SupportedCulturesStatisticsPropertyHandle - > AsArray ( ) ;
if ( ArrayPropertyHandle . IsValid ( ) )
{
ArrayPropertyHandle - > DeleteItem ( CultureIndex ) ;
}
}
}
break ;
}
}
}
}
2015-01-27 18:24:26 -05:00
# undef LOCTEXT_NAMESPACE