Bugzilla – Attachment 161599 Details for
Bug 35933
Do not translate text nodes in xsl:attribute and other tags
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35933: Do not translate text nodes in xsl:attribute and other tags
Bug-35933-Do-not-translate-text-nodes-in-xslattrib.patch (text/plain), 2.17 KB, created by
Kevin Carnes
on 2024-01-29 15:35:36 UTC
(
hide
)
Description:
Bug 35933: Do not translate text nodes in xsl:attribute and other tags
Filename:
MIME Type:
Creator:
Kevin Carnes
Created:
2024-01-29 15:35:36 UTC
Size:
2.17 KB
patch
obsolete
>From 93d6984aede9cfa31dc250c17af3df83db043138 Mon Sep 17 00:00:00 2001 >From: Kevin Carnes <kevin.carnes@ub.lu.se> >Date: Mon, 29 Jan 2024 16:30:09 +0100 >Subject: [PATCH] Bug 35933: Do not translate text nodes in xsl:attribute and > other tags > >To test: >1. Install another language >2. Notice that MARC21slim2OPACDetail.xsl has translated attributes >3. Apply patch >4. Install the language again >5. Notice that only non-attributes are translated >--- > C4/TTParser.pm | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/C4/TTParser.pm b/C4/TTParser.pm >index 7007fb6604..a407034eeb 100644 >--- a/C4/TTParser.pm >+++ b/C4/TTParser.pm >@@ -21,6 +21,7 @@ use base qw(HTML::Parser); > use C4::TmplToken; > use strict; > use warnings; >+use List::MoreUtils qw( any ); > > #seems to be handled post tokenizer > ##hash where key is tag we are interested in and the value is a hash of the attributes we want >@@ -31,6 +32,9 @@ use warnings; > #tokens found so far (used like a stack) > my ( @tokens ); > >+my $do_not_translate; >+my @do_not_translate_tags = qw( xsl:attribute ); >+ > #shiftnext token or undef > sub next_token{ > return shift @tokens; >@@ -72,7 +76,7 @@ sub text{ > my $self = shift; > my $line = shift; > my $work = shift; # original text >- my $is_cdata = shift; >+ my $is_cdata = shift || $do_not_translate; > while($work){ > # if there is a template_toolkit tag > if( $work =~ m/\[%.*?%\]/ ){ >@@ -144,6 +148,7 @@ sub start{ > my $text = shift; #original text > my $t = C4::TmplToken->new( $text, C4::TmplTokenType::TAG, $line, $self->{filename}); > my %attr; >+ $do_not_translate += 1 if any { $_ eq $tag } @do_not_translate_tags; > # tags seem to be uses in an 'interesting' way elsewhere.. > for my $key( %$hash ) { > next unless defined $hash->{$key}; >@@ -168,6 +173,7 @@ sub end{ > # what format should this be in? > my $t = C4::TmplToken->new( $text, C4::TmplTokenType::TAG, $line, $self->{filename} ); > my %attr; >+ $do_not_translate -= 1 if any { "/$_" eq $tag } @do_not_translate_tags; > # tags seem to be uses in an 'interesting' way elsewhere.. > for my $key( %$hash ) { > next unless defined $hash->{$key}; >-- >2.34.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 35933
: 161599