Bug 13700 - Translated item search not working
Summary: Translated item search not working
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-12 13:30 UTC by Katrin Fischer
Modified: 2015-12-03 22:02 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 13700: Fix item search templates for translation (2.47 KB, patch)
2015-02-13 12:37 UTC, Julian Maurice
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 13700: Fix item search templates for translation (2.84 KB, patch)
2015-02-13 13:49 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 13700: Fix item search templates for translation (2.89 KB, patch)
2015-02-13 15:46 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2015-02-12 13:30:43 UTC
Testing the new item search from available from the advanced search page in the staff client I found it only working in English, but not in its German translation.

This is a 3.18.3 installation with current templates.

The Javascript errors shown in Firebug are very unspecific - I haven't been able yet to find the source of the problem. Any help much appreciated.
Comment 1 Owen Leonard 2015-02-12 17:17:26 UTC
I see this problem too. I checked out 3.18.3, installed and switched to the German templates, and tried the item search. The search results table never renders. I don't see any errors in the Firebug console, but looking at the data being sent to DataTables I see some differences in the English versus the German output. English:

[
  "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=5515' title='Go to record detail page'>Endless ocean</a> by ",
  "",
  "Nintendo of America,",
  "",
  "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=5515#item11264' title='Go to item details'>33000000094272</a>",
  "Wii Endless",
  "The Plains",
  "The Plains",
  "",
  "",
  "",
  "0",
  "<a href='/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=5515&itemnumber=11264'>Edit</a>"
]

German:

[
 "<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=5515" title="Zur Detailansicht">Endless ocean</a> von ", "", "Nintendo of America,", "", "<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=5515#item11264" title="Zurück zu den Exemplardetails">33000000094272</a>",
 "Wii Endless",
 "The Plains",
 "The Plains",
 "",
 "",
 "",
 "0",
 "<a href='/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=5515&itemnumber=11264'>Bearbeiten</a>"
]

In the German version the quotes around HTML attributes are double quotes instead of the single quotes seen in the English version. I assume that is what is breaking things.
Comment 2 Katrin Fischer 2015-02-13 08:36:38 UTC
Thx Owen for taking the time to look at this! 

I fixed a few problems with the strings, but it still doesn't work. And the problem with the quotes does not seem to exist in the po file? I went through all strings for this template, but had no luck finding anything that would explain it.
Comment 3 Katrin Fischer 2015-02-13 08:48:41 UTC
I think this appears to be a problem with the translation script. It appears other translations that I tested this with are not complete - only in the German version of the file some things appear as translated, but not in fr-FR, nb-NO etc.
Comment 4 Katrin Fischer 2015-02-13 08:56:02 UTC
The problem also exists in the more complete es-ES translation.
Comment 5 Julian Maurice 2015-02-13 09:42:28 UTC
I think there is two different ways to fix this:

1/ Fix tmpl_process3.pl to put the same quotes (single or double) as in the original file

2/ exclude includes/catalogue/itemsearch_item.json.inc from the list of files to translate (by changing its extension ?) and use Koha::I18N for translatable text in this file

My preferences goes to 2.
What do you think ?
Comment 6 Julian Maurice 2015-02-13 09:57:52 UTC
Template parsing is done by HTML::Parser and I can't find in the doc how to know if attributes values were specified with single or double quotes. So maybe (1) is not even a solution.
Comment 7 Katrin Fischer 2015-02-13 10:32:34 UTC
Hm, What about 3)?

Could we rewrite the file in a way, that will avoid the multiple quotes? Like building the string separately and then using a variable?
Comment 8 Katrin Fischer 2015-02-13 10:33:42 UTC
I think changing the file ending would work - I have used this trick to avoid auto-translations in some other place in the past. But not a 'nice' solution.
Comment 9 Julian Maurice 2015-02-13 11:28:15 UTC
(2) will fail anyway, in case the translated string contains single quotes ... :/
Comment 10 Julian Maurice 2015-02-13 12:37:20 UTC Comment hidden (obsolete)
Comment 11 Katrin Fischer 2015-02-13 12:45:55 UTC
Yay! Thx Julian!
Comment 12 Bernardo Gonzalez Kriegel 2015-02-13 13:49:26 UTC Comment hidden (obsolete)
Comment 13 Kyle M Hall (khall) 2015-02-13 15:46:24 UTC
Created attachment 35907 [details] [review]
[PASSED QA] Bug 13700: Fix item search templates for translation

Since translator rebuild HTML tags with double quotes for attributes
values, use double quotes in english template too and escape them with
backslash.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

It works well!!

Test:
1) Intall translation  (de-DE, es-ES)
2) to Go to item search, in english, do a search that gives results
3) Switch language, repeat search, result's table does not render
4) Apply patch
5) Install translation again
6) Repeat 3, now results are displayed

No koha-qa errors

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Tomás Cohen Arazi (tcohen) 2015-02-17 02:45:39 UTC
Patch pushed to master.

Thanks Julian!
Comment 15 Chris Cormack 2015-02-22 22:57:02 UTC
String changes, held for 3.18.5
Comment 16 Chris Cormack 2015-03-01 02:27:45 UTC
Pushed to 3.18.x will be in 3.18.5