Skip to content

Commit

Permalink
Issue #3658: Renaming parameter and tidying.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaerter committed Jul 31, 2024
1 parent a82d813 commit 7483b37
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 25 deletions.
4 changes: 1 addition & 3 deletions Kernel/Modules/AdminTranslations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ sub Run {

my $Message;
my $Success = $TranslationsObject->WriteTranslationFile(
UserLanguage => $Param{UserLanguage},
TranslateParentChild => 1,
UserLanguage => $Param{UserLanguage},
) || 0;

if ( $Success == 1 ) {
Expand Down Expand Up @@ -1195,7 +1194,6 @@ sub _GetDraftTable {
%ObjectList = $Kernel::OM->Get('Kernel::System::Type')->TypeList( Valid => 0 );
}

# NOTE it is important that uniq is placed outside of sort because else sort will mistake it as sorting function
ROW:
for my $Row ( uniq sort values %ObjectList ) {

Expand Down
5 changes: 2 additions & 3 deletions Kernel/System/ImportExport/ObjectBackend/Translations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,8 @@ sub ImportDataSave {
}

$Success = $TranslationsObject->WriteTranslationFile(
UserLanguage => $Language,
Import => 0,
TranslateParentChild => 1,
UserLanguage => $Language,
Import => 0,
) || 0;

if ( !$Success ) {
Expand Down
2 changes: 0 additions & 2 deletions Kernel/System/Queue.pm
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ sub QueueAdd {
);
}

# NOTE valid defaults to 1
my %Queues = $Self->QueueList();

# generate chained translations automatically
Expand Down Expand Up @@ -1268,7 +1267,6 @@ sub QueueUpdate {
}
}

# NOTE valid defaults to 1
my %Queues = $Self->QueueList();

# generate chained translations automatically
Expand Down
2 changes: 0 additions & 2 deletions Kernel/System/Service.pm
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ sub ServiceAdd {
Type => $Self->{CacheType},
);

# NOTE valid defaults to 1
my %Services = $Self->ServiceList(
UserID => $Param{UserID},
);
Expand Down Expand Up @@ -845,7 +844,6 @@ sub ServiceUpdate {
Type => $Self->{CacheType},
);

# NOTE valid defaults to 1
my %Services = $Self->ServiceList(
UserID => $Param{UserID},
);
Expand Down
24 changes: 9 additions & 15 deletions Kernel/System/Translations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,10 @@ sub ReadExistingTranslationFile {
write translation file
my $Success = $TranslationsObject->WriteTranslationFile(
UserLanguage => 'en',
Data => { .. } #Hash of Content/Translation values,
Import => (0|1),
TranslateParentChild => (0|1), # if automatic translation of parent-child strings should be performed. Default is 1
UserLanguage => 'en',
Data => { .. } # Hash of Content/Translation values,
Import => (0|1),
NoParentChild => (0|1), # if automatic translation of parent-child strings should be performed. Default is 0
);
Returns:
Expand All @@ -623,10 +623,8 @@ sub WriteTranslationFile {
my $Data = '';
my $BreakLineAfterChars = 60;
my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home');
$Param{Import} ||= 0;

# NOTE intentionally using undef or
$Param{TranslateParentChild} //= 1;
$Param{Import} ||= 0;
$Param{NoParentChild} ||= 0;

#Check if there are draft translations to write
my @DraftTranslations = @{
Expand Down Expand Up @@ -856,15 +854,13 @@ EOF
$Success = 1;
}

if ( $Param{TranslateParentChild} ) {
if ( !$Param{NoParentChild} ) {

# NOTE valid defaults to 1
my %Queues = $Kernel::OM->Get('Kernel::System::Queue')->QueueList();
my @Strings = values %Queues;

if ( $Kernel::OM->Get('Kernel::Config')->Get('Ticket::Service') ) {

# NOTE valid defaults to 1
my %Services = $Kernel::OM->Get('Kernel::System::Service')->ServiceList(
UserID => 1,
);
Expand Down Expand Up @@ -967,8 +963,6 @@ sub TranslateParentChildElements {
# use given language, else use all system languages
my @Languages = $Param{LanguageID} ? ( $Param{LanguageID} ) : ( keys %{ $Kernel::OM->Get('Kernel::Config')->Get('DefaultUsedLanguages') } );

return unless @Languages;

# iterate over languages
for my $LanguageID (@Languages) {

Expand Down Expand Up @@ -1018,8 +1012,8 @@ sub TranslateParentChildElements {
# check if language need to be deployed to prevent recursive deployment
if ($DeployLanguage) {
my $DeploySuccess = $Self->WriteTranslationFile(
UserLanguage => $LanguageID,
TranslateParentChild => 0,
UserLanguage => $LanguageID,
NoParentChild => 1,
);
}

Expand Down

0 comments on commit 7483b37

Please sign in to comment.