Bugzilla – Attachment 149947 Details for
Bug 24975
Refactor database translations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24975: Re-introduce translated_description accessor method
Bug-24975-Re-introduce-translateddescription-acces.patch (text/plain), 7.48 KB, created by
Jonathan Druart
on 2023-04-20 12:44:40 UTC
(
hide
)
Description:
Bug 24975: Re-introduce translated_description accessor method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-20 12:44:40 UTC
Size:
7.48 KB
patch
obsolete
>From 5b42c594c0d6a5c55e5016a77e4e0fba691a3ccb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 28 Sep 2020 17:53:43 +0100 >Subject: [PATCH] Bug 24975: Re-introduce translated_description accessor > method > >--- > C4/Biblio.pm | 2 +- > C4/Items.pm | 2 +- > Koha/ItemType.pm | 14 ++++++++++++++ > authorities/authorities.pl | 2 +- > catalogue/getitem-ajax.pl | 2 +- > catalogue/itemsearch.pl | 2 +- > cataloguing/addbiblio.pl | 2 +- > circ/transferstoreceive.pl | 2 +- > opac/opac-search.pl | 2 +- > reports/reserves_stats.pl | 2 +- > svc/holds | 2 +- > 11 files changed, 24 insertions(+), 10 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index b873e32e5b2..504d597966f 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1414,7 +1414,7 @@ sub GetAuthorisedValueDesc { > my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$itypes ) { > $itypes = >- { map { $_->itemtype => db_t('itemtype', $itemtype->itemtype) } >+ { map { $_->itemtype => $_->translated_description } > Koha::ItemTypes->search()->as_list }; > $cache->set_in_cache( $cache_key, $itypes ); > } >diff --git a/C4/Items.pm b/C4/Items.pm >index 1d2d74b0f5e..5522597e0ea 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1464,7 +1464,7 @@ sub PrepareItemrecordDisplay { > push @authorised_values, ""; > while ( my $itemtype = $itemtypes->next ) { > push @authorised_values, $itemtype->itemtype; >- $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->itemtype); >+ $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; > } > if ($defaultvalues && $defaultvalues->{'itemtype'}) { > $defaultvalue = $defaultvalues->{'itemtype'}; >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index 0d21eb1334a..1f3434028f4 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -23,6 +23,7 @@ use C4::Languages; > use Koha::Caches; > use Koha::Database; > use Koha::CirculationRules; >+use Koha::I18N; > > use base qw(Koha::Object Koha::Object::Limit::Library); > >@@ -79,6 +80,19 @@ sub delete { > $self->SUPER::delete(@_); > } > >+=head3 translation_description >+ >+ my $translated_description = Koha::ItemType->translated_description; >+ >+Returns a localized string for the Koha::ItemType description field. >+ >+=cut >+ >+sub translated_description { >+ my ( $self ) = @_; >+ return dt_t('itemtype', $self->itemtype); >+} >+ > =head3 image_location > > =cut >diff --git a/authorities/authorities.pl b/authorities/authorities.pl >index 6665db62453..8bbf57040ce 100755 >--- a/authorities/authorities.pl >+++ b/authorities/authorities.pl >@@ -73,7 +73,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->itemtype); >+ $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; > } > } > else { # "true" authorised value >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >index 14667cad577..bd0e8e0d841 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->itemtype); >+ $item_unblessed->{itemtype} = $itemtype->translated_description; > } > > my $json_text = to_json( $item_unblessed, { utf8 => 1 } ); >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index 01816c27a51..f8d44520508 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -283,7 +283,7 @@ my @itemtypes; > foreach my $itemtype ( Koha::ItemTypes->search->as_list ) { > push @itemtypes, { > value => $itemtype->itemtype, >- label => db_t('itemtype', $itemtype->itemtype), >+ label => $itemtype->translated_description, > }; > } > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 07ed55d74e4..f3ace8b7016 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -201,7 +201,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->itemtype); >+ $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; > } > $value = $itemtype unless ($value); > } >diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl >index 5ab65172db0..fbd21282383 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->itemtype); >+ $getransf{'itemtype'} = $itemtype->translated_description; > %getransf = ( > %getransf, > title => $biblio->title, >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index dcafa37b47f..b2c7cc6992a 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -240,7 +240,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)->itemtype); >+ : Koha::ItemTypes->find($itemtype)->translated_description; > $itemtypes->{$itemtype}->{description} = $description || $itemtypes->{$itemtype}->{description} || q{}; > } > >diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl >index e4303901dad..5591f132308 100755 >--- a/reports/reserves_stats.pl >+++ b/reports/reserves_stats.pl >@@ -299,7 +299,7 @@ sub display_value { > my $display_value = > ( $crit =~ /ccode/ ) ? $ccodes->{$value} > : ( $crit =~ /location/ ) ? $locations->{$value} >- : ( $crit =~ /itemtype/ ) ? db_t('itemtype', Koha::ItemTypes->find( $value )->itemtype) >+ : ( $crit =~ /itemtype/ ) ? Koha::ItemTypes->find( $value )->translated_description > : ( $crit =~ /branch/ ) ? Koha::Libraries->find($value)->branchname > : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value) > : $value; # default fallback >diff --git a/svc/holds b/svc/holds >index 4bbef0c4b38..f7383595994 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->itemtype); >+ $itemtype_limit = $itemtype->translated_description; > } > > my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24975
:
101703
|
101786
|
102387
|
102388
|
102513
|
102514
|
102688
|
102701
|
132388
|
132508
|
132509
|
132510
|
132511
|
132512
|
132513
|
132514
|
132515
|
132516
|
132517
|
132518
|
132519
|
132520
|
132521
|
132522
|
132523
|
132524
|
132525
|
132526
|
132527
|
132528
|
132529
|
132530
|
132531
|
132532
|
132533
|
132546
|
132562
|
132563
|
132564
|
132565
|
132566
|
132567
|
132568
|
132569
|
132570
|
132571
|
132572
|
132573
|
132574
|
132575
|
149941
|
149942
|
149943
|
149944
|
149945
|
149946
| 149947 |
149948
|
149949
|
149950
|
149951
|
149952
|
149953
|
149954
|
149956
|
149957
|
150015
|
150033
|
150034