Bugzilla – Attachment 101070 Details for
Bug 20307
Language overlay for authorized values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20307: Replace separator with #
Bug-20307-Replace-separator-with-.patch (text/plain), 5.25 KB, created by
Jonathan Druart
on 2020-03-20 10:55:39 UTC
(
hide
)
Description:
Bug 20307: Replace separator with #
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 10:55:39 UTC
Size:
5.25 KB
patch
obsolete
>From c5ba385e4397c8c162e9d7d49ec90011b4474ebb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 20 Mar 2020 11:54:15 +0100 >Subject: [PATCH] Bug 20307: Replace separator with # > >To avoid colision we replace the separator with something that is >supposed to be less used than underscore > >The problematic case was explaing by Julian on comment 96: >""" >The value stored in localization.code is a concatenation of the AV >category code, a '_', and the AV code. Which means that if we have a >category A with a value B_C, and a category A_B with a value C, they will >share their translations. >""" >--- > Koha/AuthorisedValue.pm | 22 +++++++++++++++++++--- > Koha/Schema/Result/AuthorisedValue.pm | 2 +- > t/db_dependent/AuthorisedValues.t | 10 +++++----- > 3 files changed, 25 insertions(+), 9 deletions(-) > >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index a16e58f90c..671e26b9a2 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -71,7 +71,7 @@ sub opac_translated_description { > return $self->translated_description unless $self->lib_opac; > > my $translated_description = Koha::Localizations->search({ >- code => sprintf( "%s_%s", $self->category, $self->authorised_value ), >+ code => $self->build_code, > entity => 'authorised_values', > lang => $lang, > interface => 'opac', >@@ -97,7 +97,7 @@ sub translated_description { > } > $lang ||= C4::Languages::getlanguage; > my $translated_description = Koha::Localizations->search({ >- code => sprintf( "%s_%s", $self->category, $self->authorised_value ), >+ code => $self->build_code, > entity => 'authorised_values', > lang => $lang, > })->next; >@@ -114,7 +114,7 @@ sub translated_descriptions { > my ( $self ) = @_; > my @translated_descriptions = Koha::Localizations->search( > { entity => 'authorised_values', >- code => sprintf( "%s_%s", $self->category, $self->authorised_value ), >+ code => $self->build_code, > } > ); > return [ map { >@@ -134,6 +134,22 @@ sub image_location { > return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl ); > } > >+=head3 build_code >+ >+my $code = $av->build_code; >+ >+Return the "code" used by the translation mecanism to identify a row. >+It is a concatenation of category and authorised_value. >+ >+Note that is is also used in Koha/Schema/Result/AuthorisedValue.pm >+ >+=cut >+ >+sub build_code { >+ my ( $self ) = @_; >+ return sprintf "%s#%s", $self->category, $self->authorised_value; >+} >+ > =head3 _type > > =cut >diff --git a/Koha/Schema/Result/AuthorisedValue.pm b/Koha/Schema/Result/AuthorisedValue.pm >index e6a9b1bfa0..e42d388cf6 100644 >--- a/Koha/Schema/Result/AuthorisedValue.pm >+++ b/Koha/Schema/Result/AuthorisedValue.pm >@@ -159,7 +159,7 @@ __PACKAGE__->has_many( > die "no interface specified!" unless $INTERFACE; > > return ({ >- "$args->{foreign_alias}.code" => \["= CONCAT(me.category, '_', me.authorised_value)"], >+ "$args->{foreign_alias}.code" => \["= CONCAT(me.category, '#', me.authorised_value)"], > "$args->{foreign_alias}.lang" => $LANGUAGE, > "$args->{foreign_alias}.interface" => $INTERFACE, > }); >diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t >index a8c29341f7..6702267d5e 100644 >--- a/t/db_dependent/AuthorisedValues.t >+++ b/t/db_dependent/AuthorisedValues.t >@@ -259,7 +259,7 @@ subtest "localization" => sub { > Koha::Localization->new( > { > entity => 'authorised_values', >- code => sprintf( "%s_%s", $av1->category, $av1->authorised_value ), >+ code => $av1->build_code, > lang => 'es-ES', > interface => 'intranet', > translation => 'traducción 1' >@@ -268,7 +268,7 @@ subtest "localization" => sub { > Koha::Localization->new( > { > entity => 'authorised_values', >- code => sprintf( "%s_%s", $av1->category, $av1->authorised_value ), >+ code => $av1->build_code, > lang => 'es-ES', > interface => 'opac', > translation => 'opac traducción 1' >@@ -277,7 +277,7 @@ subtest "localization" => sub { > Koha::Localization->new( > { > entity => 'authorised_values', >- code => sprintf( "%s_%s", $av1->category, $av2->authorised_value ), >+ code => $av2->build_code, > lang => 'es-ES', > interface => 'intranet', > translation => 'traducción 2' >@@ -287,7 +287,7 @@ subtest "localization" => sub { > Koha::Localization->new( > { > entity => 'authorised_values', >- code => sprintf( "%s_%s", $av1->category, $av1->authorised_value ), >+ code => $av1->build_code, > lang => 'fr-FR', > interface => 'intranet', > translation => 'traduction 1' >@@ -296,7 +296,7 @@ subtest "localization" => sub { > Koha::Localization->new( > { > entity => 'authorised_values', >- code => sprintf( "%s_%s", $av2->category, $av2->authorised_value ), >+ code => $av2->build_code, > lang => 'de-DE', > interface => 'intranet', > translation => 'Ãbersetzung 2' >-- >2.20.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 20307
:
86622
|
86623
|
86624
|
86625
|
86626
|
86627
|
89538
|
91645
|
91646
|
91647
|
91648
|
91649
|
91650
|
91651
|
91653
|
92192
|
92193
|
92359
|
92360
|
92361
|
94245
|
94246
|
94247
|
94248
|
94249
|
94250
|
94251
|
94252
|
94253
|
94254
|
94255
|
94256
|
94700
|
94701
|
94702
|
94703
|
94704
|
94705
|
94706
|
94707
|
94708
|
94709
|
94710
|
94711
|
97074
|
97075
|
98863
|
98864
|
98865
|
98866
|
98867
|
98868
|
98869
|
98870
|
98871
|
98872
|
98873
|
98874
|
98875
|
98876
| 101070 |
101450