From 2f3fbf71d91fdf1a65fd6bc597bb3a3aec2f7637 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 15 Sep 2020 13:55:11 +0100 Subject: [PATCH] Bug 24975: Use 'key' for translation lookup This patch switches from using the original text as a key for translations to using a dedicated 'key' field. We also add in a 'fuzzy' flag to denote when the source text has changed and as such the pre-existing translations may be incorrect. ToDo: 1/ Expose 'Fuzzy' on the 'Localization' admin page 2/ Add a 'translation_key' method to Koha::Itemtype to encourage the adoption of a standardly names accessor to get the 'translation_key' from a Koha::Object derived class. --- C4/Biblio.pm | 2 +- C4/Items.pm | 2 +- C4/Search.pm | 6 ++--- Koha/DBIx/Component/L10nSource.pm | 27 ++++++++++--------- Koha/I18N.pm | 26 +++++++++--------- Koha/Schema/Result/Itemtype.pm | 12 ++++----- Koha/Template/Plugin/ItemTypes.pm | 4 +-- acqui/orderreceive.pl | 1 - authorities/authorities.pl | 2 +- catalogue/getitem-ajax.pl | 2 +- catalogue/itemsearch.pl | 2 +- catalogue/moredetail.pl | 4 +-- catalogue/search.pl | 2 +- cataloguing/addbiblio.pl | 2 +- circ/transferstoreceive.pl | 2 +- .../data/mysql/atomicupdate/bug-24975.perl | 20 +++++++------- installer/data/mysql/kohastructure.sql | 27 ++++++++++++------- .../prog/en/modules/admin/localization.tt | 5 ++++ opac/opac-detail.pl | 4 +-- opac/opac-search.pl | 2 +- reports/issues_stats.pl | 4 +-- reports/reserves_stats.pl | 2 +- svc/checkouts | 2 +- svc/holds | 2 +- 24 files changed, 89 insertions(+), 75 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 807258e2aa..2ff808bcad 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1448,7 +1448,7 @@ sub GetAuthorisedValueDesc { #---- itemtypes if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) { my $itemtype = Koha::ItemTypes->find( $value ); - return $itemtype ? db_t('itemtype', $itemtype->description) : q||; + return $itemtype ? db_t('itemtype', $itemtype->itemtype) : q||; } if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) { diff --git a/C4/Items.pm b/C4/Items.pm index 4d48aedb1f..389aa9e0d9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1723,7 +1723,7 @@ sub PrepareItemrecordDisplay { push @authorised_values, ""; while ( my $itemtype = $itemtypes->next ) { push @authorised_values, $itemtype->itemtype; - $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description); + $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->itemtype); } if ($defaultvalues && $defaultvalues->{'itemtype'}) { $defaultvalue = $defaultvalues->{'itemtype'}; diff --git a/C4/Search.pm b/C4/Search.pm index 3624bbb96c..780948c307 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -530,7 +530,7 @@ sub getRecords { && ref( $itemtypes->{$one_facet} ) eq "HASH" ) { - $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{description}); + $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{itemtype}); } } @@ -1733,7 +1733,7 @@ sub searchResults { # add imageurl to itemtype if there is one $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{}; # Build summary if there is one (the summary is defined in the itemtypes table) - $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{description}) : q{}; + $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{itemtype}) : q{}; # Pull out the items fields my @fields = $marcrecord->field($itemtag); @@ -1799,7 +1799,7 @@ sub searchResults { foreach my $code ( keys %subfieldstosearch ) { $item->{$code} = $field->subfield( $subfieldstosearch{$code} ); } - $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{description}) if $item->{itype}; + $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{itemtype}) if $item->{itype}; # OPAC hidden items if ($is_opac) { diff --git a/Koha/DBIx/Component/L10nSource.pm b/Koha/DBIx/Component/L10nSource.pm index 933638e834..1a3a4c0a9c 100644 --- a/Koha/DBIx/Component/L10nSource.pm +++ b/Koha/DBIx/Component/L10nSource.pm @@ -49,19 +49,22 @@ Update or create an entry in l10n_source =cut sub update_l10n_source { - my ($self, $group, $key, $text) = @_; + my ( $self, $group, $key, $source_text ) = @_; - my $l10n_source_rs = $self->result_source->schema->resultset('L10nSource'); - $l10n_source_rs->update_or_create( - { - group => $group, - key => $key, - text => $text, - }, - { - key => 'group_key', - } - ); + my $l10n_source_rs = + $self->result_source->schema->resultset('L10nSource') + ->find( { group => $group, key => $key }, { key => 'group_key' } ); + + if ($l10n_source_rs) { + $l10n_source_rs->update( { text => $source_text } ); + my $l10n_target_rs = $l10n_source_rs->l10n_targets_rs; + $l10n_target_rs->update( { fuzzy => 1 } ); + } + else { + $l10n_source_rs = + $self->result_source->schema->resultset('L10nSource') + ->create( { group => $group, key => $key, text => $source_text } ); + } } =head2 delete_l10n_source diff --git a/Koha/I18N.pm b/Koha/I18N.pm index 96e9bd26d1..ac56b44da0 100644 --- a/Koha/I18N.pm +++ b/Koha/I18N.pm @@ -228,8 +228,8 @@ sub _expand { =head2 db_t - db_t($group, $text) - db_t('itemtype', $itemtype->description) + db_t($group, $key) + db_t('itemtype', $itemtype->itemtype) Search for a translation in l10n_target table and return it if found Return C<$text> otherwise @@ -237,7 +237,7 @@ Return C<$text> otherwise =cut sub db_t { - my ($group, $text) = @_; + my ($group, $key) = @_; my $cache = Koha::Caches->get_instance(); unless ($cache->is_cache_active) { @@ -249,29 +249,27 @@ sub db_t { my $translations = $cache->get_from_cache($cache_key); unless ($translations) { my $schema = Koha::Database->new->schema; - my $rs = $schema->resultset('L10nTarget'); + my $rs = $schema->resultset('L10nSource'); my @targets = $rs->search( { - 'l10n_source.group' => $group, - language => $language, + 'group' => $group, + 'l10n_target.language' => $language, }, { - join => 'l10n_source', - prefetch => 'l10n_source', + join => 'l10n_target', + prefetch => 'l10n_target', result_class => 'DBIx::Class::ResultClass::HashRefInflator', }, ); - $translations = { map { $_->{l10n_source}->{text} => $_->{translation} } @targets }; + $translations = + { map { $_->{key} => $_->{l10n_target}->{translation} // $_->{text} } + @targets }; $cache->set_in_cache($cache_key, $translations); } - if (exists $translations->{$text}) { - return $translations->{$text}; - } - - return $text; + return $translations->{$key}; } 1; diff --git a/Koha/Schema/Result/Itemtype.pm b/Koha/Schema/Result/Itemtype.pm index c63684eaaf..5ccc73642e 100644 --- a/Koha/Schema/Result/Itemtype.pm +++ b/Koha/Schema/Result/Itemtype.pm @@ -356,7 +356,7 @@ sub insert { my $result = $self->next::method(@_); - $self->update_l10n_source('itemtype', $self->itemtype, $self->description); + $self->update_l10n_source( 'itemtype', $self->itemtype, $self->description ); return $result; } @@ -366,21 +366,21 @@ sub update { my $is_description_changed = $self->is_column_changed('description'); - my $result = $self->next::method(@_); - if ($is_description_changed) { - $self->update_l10n_source('itemtype', $self->itemtype, $self->description); + $self->update_l10n_source( 'itemtype', $self->itemtype, $self->description ); } + my $result = $self->next::method(@_); + return $result; } sub delete { my $self = shift; - my $result = $self->next::method(@_); + $self->delete_l10n_source( 'itemtype', $self->itemtype ); - $self->delete_l10n_source('itemtype', $self->itemtype); + my $result = $self->next::method(@_); return $result; } diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm index 6239473ea5..95aa51abe2 100644 --- a/Koha/Template/Plugin/ItemTypes.pm +++ b/Koha/Template/Plugin/ItemTypes.pm @@ -39,9 +39,9 @@ sub Get { } sub t { - my ($self, $description) = @_; + my ($self, $key) = @_; - return db_t('itemtype', $description); + return db_t('itemtype', $key); } 1; diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 1f0243527a..e2ebb91822 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -115,7 +115,6 @@ unless($acq_fw) { $template->param('NoACQframework' => 1); } - my $creator = Koha::Patrons->find( $order->created_by ); my $budget = GetBudget( $order->budget_id ); diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 8a8f650378..e2e428ba29 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -88,7 +88,7 @@ sub build_authorized_values_list { unless ( $tagslib->{$tag}->{$subfield}->{mandatory} && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) ); push @authorised_values, $itemtype->itemtype; - $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description); + $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->itemtype); } } else { # "true" authorised value diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl index 43e5a0945c..14667cad57 100755 --- a/catalogue/getitem-ajax.pl +++ b/catalogue/getitem-ajax.pl @@ -76,7 +76,7 @@ if($itemnumber) { my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); # We should not do that here, but call ->itemtype->description when needed instea - $item_unblessed->{itemtype} = db_t('itemtype', $itemtype->description); + $item_unblessed->{itemtype} = db_t('itemtype', $itemtype->itemtype); } my $json_text = to_json( $item_unblessed, { utf8 => 1 } ); diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index e632f0a8c8..ec6a6b0b48 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -282,7 +282,7 @@ my @itemtypes; foreach my $itemtype ( Koha::ItemTypes->search->as_list ) { push @itemtypes, { value => $itemtype->itemtype, - label => db_t('itemtype', $itemtype->description), + label => db_t('itemtype', $itemtype->itemtype), }; } diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 7a45950e38..2cee5e213b 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -145,7 +145,7 @@ my $copynumbers = my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; -$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{description}) +$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{itemtype}) if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} }; foreach ( keys %{$data} ) { $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); @@ -155,7 +155,7 @@ foreach ( keys %{$data} ) { foreach my $item (@items){ $item->{object} = Koha::Items->find( $item->{itemnumber} ); $item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; - $item->{'itype'} = db_t('itemtype', $itemtypes->{ $item->{'itype'} }->{description}) if exists $itemtypes->{ $item->{'itype'} }; + $item->{'itype'} = db_t('itemtype', $itemtypes->{ $item->{'itype'} }->{itemtype}) if exists $itemtypes->{ $item->{'itype'} }; $item->{'replacementprice'} = $item->{'replacementprice'}; if ( defined $item->{'copynumber'} ) { $item->{'displaycopy'} = 1; diff --git a/catalogue/search.pl b/catalogue/search.pl index 1f102a45ed..bac29505b0 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -734,7 +734,7 @@ sub prepare_adv_search_types { map { $_->{itemtype} => { %$_, - description => db_t( 'itemtype', $_->{description} ), + description => db_t( 'itemtype', $_->{itemtype} ), } } @{ Koha::ItemTypes->search->unblessed } }; diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 560e55aa44..da9e7f271c 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -196,7 +196,7 @@ sub build_authorized_values_list { my $itemtypes = Koha::ItemTypes->search; while ( $itemtype = $itemtypes->next ) { push @authorised_values, $itemtype->itemtype; - $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description); + $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->itemtype); } $value = $itemtype unless ($value); } diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index d2daa3b539..7e902c8f94 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -88,7 +88,7 @@ while ( my $library = $libraries->next ) { my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); $getransf{'datetransfer'} = $num->{'datesent'}; - $getransf{'itemtype'} = db_t('itemtype', $itemtype->description); + $getransf{'itemtype'} = db_t('itemtype', $itemtype->itemtype); %getransf = ( %getransf, title => $biblio->title, diff --git a/installer/data/mysql/atomicupdate/bug-24975.perl b/installer/data/mysql/atomicupdate/bug-24975.perl index 66d0319928..011fe02361 100644 --- a/installer/data/mysql/atomicupdate/bug-24975.perl +++ b/installer/data/mysql/atomicupdate/bug-24975.perl @@ -2,25 +2,25 @@ $DBversion = 'XXX'; if( CheckVersion( $DBversion ) ) { $dbh->do(q{ CREATE TABLE IF NOT EXISTS l10n_source ( - l10n_source_id INT(11) NOT NULL AUTO_INCREMENT, + `l10n_source_id` INT(11) NOT NULL AUTO_INCREMENT, `group` VARCHAR(100) NULL DEFAULT NULL, `key` VARCHAR(100) NOT NULL, `text` TEXT NOT NULL, PRIMARY KEY (l10n_source_id), - UNIQUE KEY group_key (`group`, `key`), - KEY group_text (`group`, `text`(60)) + UNIQUE KEY group_text (`group`, `key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; }); $dbh->do(q{ CREATE TABLE IF NOT EXISTS l10n_target ( - l10n_target_id INT(11) NOT NULL AUTO_INCREMENT, - l10n_source_id INT(11) NOT NULL, - language VARCHAR(10) NOT NULL, - translation TEXT NOT NULL, + `l10n_target_id` INT(11) NOT NULL AUTO_INCREMENT, + `l10n_source_id` INT(11) NOT NULL, + `language` VARCHAR(10) NOT NULL, + `translation` TEXT NOT NULL, + `fuzzy` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (l10n_target_id), UNIQUE KEY l10n_source_language (l10n_source_id, language), - FOREIGN KEY l10n_source (l10n_source_id) REFERENCES l10n_source (l10n_source_id) + CONSTRAINT `l10n_target_fk` FOREIGN KEY (`l10n_source_id`) REFERENCES `l10n_source` (`l10n_source_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; }); @@ -37,11 +37,11 @@ if( CheckVersion( $DBversion ) ) { SELECT DISTINCT l10n_source_id, lang, translation FROM localization JOIN itemtypes ON (localization.code = itemtypes.itemtype) - JOIN l10n_source ON (itemtypes.itemtype = l10n_source.`key` AND l10n_source.`group` = 'itemtype') + JOIN l10n_source ON (itemtypes.description = l10n_source.`text` AND l10n_source.`group` = 'itemtype') WHERE entity = 'itemtypes' }); - $dbh->do('DROP TABLE localization'); + #$dbh->do('DROP TABLE localization'); } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 70c59b5812..e5cbe94a34 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3203,29 +3203,38 @@ CREATE TABLE `keyboard_shortcuts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `l10n_source` +-- DROP TABLE IF EXISTS l10n_source; CREATE TABLE l10n_source ( - l10n_source_id INT(11) NOT NULL AUTO_INCREMENT, + `l10n_source_id` INT(11) NOT NULL AUTO_INCREMENT, `group` VARCHAR(100) NULL DEFAULT NULL, `key` VARCHAR(100) NOT NULL, `text` TEXT NOT NULL, PRIMARY KEY (l10n_source_id), - UNIQUE KEY group_key (`group`, `key`), - KEY group_text (`group`, `text`(60)) + UNIQUE KEY group_key (`group`, `key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `l10n_target` +-- DROP TABLE IF EXISTS l10n_target; CREATE TABLE l10n_target ( - l10n_target_id INT(11) NOT NULL AUTO_INCREMENT, - l10n_source_id INT(11) NOT NULL, - language VARCHAR(10) NOT NULL, - translation TEXT NOT NULL, + `l10n_target_id` INT(11) NOT NULL AUTO_INCREMENT, + `l10n_source_id` INT(11) NOT NULL, + `language` VARCHAR(10) NOT NULL, + `translation` TEXT NOT NULL, + `fuzzy` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (l10n_target_id), UNIQUE KEY l10n_source_language (l10n_source_id, language), - FOREIGN KEY l10n_source (l10n_source_id) REFERENCES l10n_source (l10n_source_id) + CONSTRAINT `l10n_target_fk` FOREIGN KEY (`l10n_source_id`) REFERENCES `l10n_source` (`l10n_source_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `language_descriptions` @@ -4526,7 +4535,7 @@ CREATE TABLE `saved_sql` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `search_field` + -- DROP TABLE IF EXISTS `search_field`; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt index 683b8e460f..cf1d244ab7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt @@ -46,6 +46,7 @@ Group + Key Text Translations @@ -92,6 +93,10 @@ name: 'group', data: 'group', }, + { + name: 'key', + data: 'key', + }, { name: 'text', data: 'text', diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 49b8e5852f..fed23f8dc2 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -546,7 +546,7 @@ my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unble my $itemtype = $dat->{'itemtype'}; if ( $itemtype ) { $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); - $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{description}); + $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{itemtype}); } my $shelflocations = @@ -725,7 +725,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { } if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); - $itm->{'description'} = db_t('itemtype', $itemtypes->{ $itm->{itype} }->{description}); + $itm->{'description'} = db_t('itemtype', $itemtypes->{ $itm->{itype} }->{itemtype}); } foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) { $itemfields{$_} = 1 if ($itm->{$_}); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index ae7f698359..cdb2666580 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -231,7 +231,7 @@ foreach my $itemtype ( keys %{$itemtypes} ) { # If 'iscat' (see ITEMTYPECAT) then there is no itemtype and the description is not translated my $description = $itemtypes->{$itemtype}->{iscat} ? $itemtypes->{$itemtype}->{description} - : db_t('itemtype', Koha::ItemTypes->find($itemtype)->description); + : db_t('itemtype', Koha::ItemTypes->find($itemtype)->itemtype); $itemtypes->{$itemtype}->{description} = $description || $itemtypes->{$itemtype}->{description} || q{}; } diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 52c2687fc9..73c049049b 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -351,7 +351,7 @@ sub calculate { $cell{rowtitle_display} = ( $line =~ /ccode/ ) ? $ccodes->{$celvalue} : ( $line =~ /location/ ) ? $locations->{$celvalue} - : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description}) + : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype}) : $celvalue; # default fallback if ( $line =~ /sort1/ ) { foreach (@$Bsort1) { @@ -440,7 +440,7 @@ sub calculate { $cell{coltitle_display} = ( $column =~ /ccode/ ) ? $ccodes->{$celvalue} : ( $column =~ /location/ ) ? $locations->{$celvalue} - : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description}) + : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype}) : $celvalue; # default fallback if ( $column =~ /sort1/ ) { foreach (@$Bsort1) { diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index 06fce11a6c..805113ad2c 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -309,7 +309,7 @@ sub display_value { my $display_value = ( $crit =~ /ccode/ ) ? $ccodes->{$value} : ( $crit =~ /location/ ) ? $locations->{$value} - : ( $crit =~ /itemtype/ ) ? db_t('itemtype', Koha::ItemTypes->find( $value )->description) + : ( $crit =~ /itemtype/ ) ? db_t('itemtype', Koha::ItemTypes->find( $value )->itemtype) : ( $crit =~ /branch/ ) ? Koha::Libraries->find($value)->branchname : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value) : $value; # default fallback diff --git a/svc/checkouts b/svc/checkouts index 21ccabcad3..945fa4fa98 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -147,7 +147,7 @@ my $item_level_itypes = C4::Context->preference('item-level_itypes'); my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue'); my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts"); -my $itemtypes = { map { $_->{itemtype} => db_t('itemtypes', $_->{itemtype}) } @{ Koha::ItemTypes->search->unblessed } }; +my $itemtypes = { map { $_->{itemtype} => db_t('itemtype', $_->{itemtype}) } @{ Koha::ItemTypes->search->unblessed } }; my @checkouts_today; my @checkouts_previous; diff --git a/svc/holds b/svc/holds index f474464f48..f537154495 100755 --- a/svc/holds +++ b/svc/holds @@ -82,7 +82,7 @@ while ( my $h = $holds_rs->next() ) { my $itemtype_limit; if ( $h->itemtype ) { my $itemtype = Koha::ItemTypes->find( $h->itemtype ); - $itemtype_limit = db_t('itemtype', $itemtype->description); + $itemtype_limit = db_t('itemtype', $itemtype->itemtype); } my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; -- 2.20.1