Bug 18634: Handle colliding translation for preference sections

Problem on this report was caused by translating the tabs Privacy
and Payments by the same string. This caused overwriting a hash entry.

This patch tests if the key already exists and if so, it merges the
entries instead of overwriting the old contents.

Test plan:
[1] Make sure that e.g. Privacy and Payments translate to e.g Vie privee.
[2] Run translate install fr-CA (or the language you altered)
[3] Without this patch you should loose preferences from either Privacy or
    Payments. With this patch, they should be merged.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested with fr-CA.

Signed-off-by: Blou <philippe.blouin@inlibro.com>
Reset the .po files, reproduced the problem.  Applied the patch and suddenly 'paypal' appeared.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2017-06-14 15:37:55 +02:00 committed by Jonathan Druart
parent 83e4adf0ab
commit 0d98089ec7
1 changed files with 6 additions and 1 deletions

View File

@ -336,7 +336,12 @@ sub install_prefs {
my $id = $self->{file} . " $section";
my $text = $self->get_trans_text($id);
my $nsection = $text ? $text : $section;
$ntab->{$nsection} = $tab_content->{$section};
if( exists $ntab->{$nsection} ) {
# When translations collide (see BZ 18634)
push @{$ntab->{$nsection}}, @{$tab_content->{$section}};
} else {
$ntab->{$nsection} = $tab_content->{$section};
}
}
$pref->{$tab} = $ntab;
}