Bugzilla – Attachment 170342 Details for
Bug 36171
Extraction of Template Toolkit directive as translatable string causes patron view error in several languages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36171: Fix template toolkit tags split by HTML parser
Bug-36171-Fix-template-toolkit-tags-split-by-HTML-.patch (text/plain), 5.40 KB, created by
Kevin Carnes
on 2024-08-15 09:10:16 UTC
(
hide
)
Description:
Bug 36171: Fix template toolkit tags split by HTML parser
Filename:
MIME Type:
Creator:
Kevin Carnes
Created:
2024-08-15 09:10:16 UTC
Size:
5.40 KB
patch
obsolete
>From a92ba07b1b9d2dc034387dfe892fb886173327f6 Mon Sep 17 00:00:00 2001 >From: Kevin Carnes <kevin.carnes@ub.lu.se> >Date: Mon, 12 Aug 2024 10:55:57 +0200 >Subject: [PATCH] Bug 36171: Fix template toolkit tags split by HTML parser > >It appears that the template parser parses HTML tags first and then template >toolkit tags. This can cause a template toolkit tag that contains an HTML tag >to have its start and end markers separated. This causes it to be treated as >text that can be translated instead of a template toolkit tag. > >This patch searches for text sections that have a template toolkit end marker >without a start and then searches for the start in previous sections. It then >creates a new template toolkit section with the start and end markers. > >The action buttons in the staff Lists view have been changed to allow >translation. > >To test: >1. You will need to edit the staff-prog.po for a language and modify the > the translation for "SET line_break". You can change SET to FOO. >2. Install the translation for the language. >3. View the details of a patron in the staff interface with the language. >4. The page will have an error. >5. Apply the patch. >6. Install the translation for the language. >7. View the details of a patron in the staff interface with the language. >8. The page should now display correctly. > >If you want to, you can run "gulp po:update --lang LANGUAGE-CODE" to make sure >that the template tag is no longer included in .po file. > >You can also add translations for "Edit", "Delete", and "Transfer" in >messages.po to make sure that the action buttons are translated in the Lists >view. >--- > C4/TTParser.pm | 16 ++++++++++++++++ > .../virtualshelves/tables/shelves_results.tt | 6 +++--- > 2 files changed, 19 insertions(+), 3 deletions(-) > >diff --git a/C4/TTParser.pm b/C4/TTParser.pm >index 7007fb6604..b0c09cdff2 100644 >--- a/C4/TTParser.pm >+++ b/C4/TTParser.pm >@@ -73,6 +73,22 @@ sub text{ > my $line = shift; > my $work = shift; # original text > my $is_cdata = shift; >+ # If there is a split template toolkit tag >+ if( $work =~ m/^(?:(?!\[%).)*?%\]/s ) { >+ my @strings = ($&); >+ my $token; >+ $work = $'; >+ while($token = pop @tokens){ >+ if ( $token->string =~ m/\[%.*?$/s ) { >+ push @tokens, C4::TmplToken->new( $`, $token->type, $token->line_number, $token->pathname ); >+ push @strings, $&; >+ last; >+ } else { >+ push @strings, $token->string; >+ } >+ } >+ push @tokens, C4::TmplToken->new( join('', reverse @strings), C4::TmplTokenType::DIRECTIVE, $token ? $token->line_number : $line, $self->{filename} ); >+ } > while($work){ > # if there is a template_toolkit tag > if( $work =~ m/\[%.*?%\]/ ){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >index de301479f3..abc6272c1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >@@ -43,7 +43,7 @@ > [%~ action_block = action_block _ '<input type="hidden" name="op" value="edit_form" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="public" value="' _ public _ '" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%] >- [%~ action_block = action_block _ '<button class="editshelf btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</button>' ~%] >+ [%~ action_block = action_block _ '<button class="editshelf btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' _ t("Edit") _ '</button>' ~%] > [%~ action_block = action_block _ '</form> ' ~%] > [%~ END ~%] > [%~ IF can_delete_shelf ~%] >@@ -54,7 +54,7 @@ > [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="public" value="' _ public _ '" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%] >- [%~ action_block = action_block _ '<button type="submit" class="delete-list btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</button>' ~%] >+ [%~ action_block = action_block _ '<button type="submit" class="delete-list btn btn-default btn-xs"><i class="fa fa-trash-can"></i> ' _ t("Delete") _ '</button>' ~%] > [%~ action_block = action_block _ '</form>' ~%] > [%~ END ~%] > [%~ IF public AND allow_transfer ~%] >@@ -64,7 +64,7 @@ > [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="public" value="1" />' ~%] > [%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%] >- [%~ action_block = action_block _ '<button type="submit" class="btn btn-default btn-xs"><i class="fa"></i> Transfer</button>' ~%] >+ [%~ action_block = action_block _ '<button type="submit" class="btn btn-default btn-xs"><i class="fa"></i> ' _ t("Transfer") _ '</button>' ~%] > [%~ action_block = action_block _ '</form>' ~%] > [%~ END ~%] > [%~ ELSE ~%] >-- >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 36171
:
162490
|
162516
|
165506
|
170194
|
170195
|
170227
|
170262
|
170342
|
172327
|
172334
|
173252