Bug 24223: (QA follow-up) Do not copy to other languages

By majority on Bugzilla, we dont want to have the existing text in all
translatable languages.

Note: Removing the news_123 as code here, switching to OpacNav now.
Another report should handle/improve the use of code, assuming that
it is meant to provide some form of grouping. There is now confusion
between the fields code and location.

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2021-10-19 11:36:11 +00:00 committed by Jonathan Druart
parent b5b147df0a
commit dbec2d4951
1 changed files with 3 additions and 23 deletions

View File

@ -7,35 +7,15 @@ return {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
# get list of installed translations
require C4::Languages;
my @langs;
my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
foreach my $language ( @$tlangs ) {
foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
push @langs, $sublanguage->{'rfc4646_subtag'};
}
}
# There must be a "default" entry in addition to language-specific ones
push @langs, "default";
# Get any existing value from the OpacNav system preference
my ($opacnav) = $dbh->selectrow_array( q|
SELECT value FROM systempreferences WHERE variable='OpacNav';
|);
if( $opacnav ){
# If there is a value in the OpacNav preference, insert it into additional_contents
my $code = '';
foreach my $lang ( @langs ) {
say $out "Inserting OpacNav contents into $lang news item...";
$dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', '', 'OpacNav', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacNav $lang", $opacnav, $lang );
my $idnew = $dbh->last_insert_id(undef, undef, 'additional_contents', undef);
if( $code eq '' ){
$code = "News_$idnew";
}
$dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew);
foreach my $lang ( 'default' ) {
say $out "Inserting OpacNav contents into default";
$dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacNav', 'OpacNav', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacNav $lang", $opacnav, $lang );
}
# Remove the OpacNav system preference