Bug 7821 - XSLT systempreference multi-language support
Summary: XSLT systempreference multi-language support
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: 3.8
Hardware: All All
: P5 - low blocker (vote)
Assignee: Dobrica Pavlinusic
QA Contact: Ian Walls
URL:
Keywords:
Depends on: 4032
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-24 17:06 UTC by Dobrica Pavlinusic
Modified: 2019-06-27 09:24 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:


Attachments
Bug 7821 - {langcode} will be replaced with current interface language (4.48 KB, patch)
2012-03-24 17:11 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 7821 - {langcode} will be replaced with current interface language (5.02 KB, patch)
2012-03-26 04:57 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7821 - fix C4::Templates::_current_language (807 bytes, patch)
2012-03-30 17:44 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Followup for current language call (928 bytes, patch)
2012-03-30 17:58 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Dobrica Pavlinusic 2012-03-24 17:06:42 UTC
There was discussion on bug 4032 that multi-language support is important.
Comment 1 Dobrica Pavlinusic 2012-03-24 17:11:54 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2012-03-26 04:57:01 UTC Comment hidden (obsolete)
Comment 3 Paul Poulain 2012-03-29 10:14:38 UTC
QA comment: small patch, nothing to say, passed QA.

Must be applied after 4032

passed QA
Comment 4 Marcel de Rooy 2012-03-29 11:34:38 UTC
Just mentioning: Think the test /{langcode}/ works, but to my knowledge(..) curly braces should better be escaped in a regex. Normally they are used for repetition (a{2} means two characters a).
Comment 5 Dobrica Pavlinusic 2012-03-29 13:46:09 UTC
I agree. Something like \Q{langcode}\E would be much better. Should I re-submit patch or can QA fix this?
Comment 6 Paul Poulain 2012-03-29 15:26:47 UTC
(In reply to comment #5)
> I agree. Something like \Q{langcode}\E would be much better. Should I
> re-submit patch or can QA fix this?

I've fixed it, by using \{ and \}

It work fine, thanks.

Note that the result will be broken if you use {langcode} but don't provide a localised stylesheet for each language

For example, you have 
en/stylesheet.xsl
fr-FR/stylesheet.xsl
set the syspref to
{langcode}/stylesheet.xsl

and activate german at the OPAC: displaying in english and french will be OK, in german, you'll get a nasty Perl error. Worth specifying it in the documentation!
Comment 7 Owen Leonard 2012-03-30 15:58:06 UTC
I'm getting an error from /cgi-bin/koha/virtualshelves/shelves.pl which git bisect blames on the latest commit from this bug (f91bd36399b1ab46649482f80e0ff1b438a8d9f6):

Bareword "C4::Templates::_current_language" not allowed while "strict subs" in use at /home/oleonard/kohaclone/C4/XSLT.pm line 175.
Comment 8 Dobrica Pavlinusic 2012-03-30 17:44:44 UTC Comment hidden (obsolete)
Comment 9 Marcel de Rooy 2012-03-30 17:58:55 UTC
Created attachment 8725 [details] [review]
Followup for current language call
Comment 10 Marcel de Rooy 2012-03-30 18:00:20 UTC
QA Comment: Trivial fix.
Comment 11 Katrin Fischer 2012-03-31 17:46:05 UTC
Updatig severity - last patch if fixing a bug, not an enhancement.
Comment 12 Katrin Fischer 2012-03-31 20:37:55 UTC
Updating severity again...

Cron <...> $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null (failed)

Bareword "C4::Templates::_current_language" not allowed while "strict subs" in use at /home/katrin/kohaclone/C4/XSLT.pm line 175.
Compilation failed in require at /home/katrin/kohaclone/C4/Search.pm line 29.
BEGIN failed--compilation aborted at /home/katrin/kohaclone/C4/Search.pm line 29.
Compilation failed in require at /home/katrin/kohaclone/C4/AuthoritiesMarc.pm line 24.
BEGIN failed--compilation aborted at /home/katrin/kohaclone/C4/AuthoritiesMarc.pm line 24.
Compilation failed in require at /home/katrin/kohaclone/misc/cronjobs/../migration_tools/rebuild_zebra.pl line 11.
BEGIN failed--compilation aborted at /home/katrin/kohaclone/misc/cronjobs/../migration_tools/rebuild_zebra.pl line 11.
Comment 13 Srdjan Jankovic 2012-04-02 00:47:18 UTC
Bareword "C4::Templates::_current_language" not allowed while "strict subs" in use at C4/XSLT.pm line 175.
Compilation failed in require at C4/Search.pm line 29.

It seems that $ is missing from C4::Templates::_current_language in C4/XSLT.pm
Comment 14 Chris Cormack 2012-04-02 00:50:41 UTC
Srdjan the latest patch the follow up, is the fix for that, it needs to be pushed ASAP, because master is currently broken until it is
Comment 15 Srdjan Jankovic 2012-04-02 01:35:18 UTC
Yes, I should be more observant and read all the comments as opposed to be lazy...
Comment 16 Paul Poulain 2012-04-02 09:37:33 UTC
Patch pushed, if someone can explain why the () fixes the problem (or why, without () there is a problem), i'd like to have it !!!
Comment 17 Srdjan Jankovic 2012-04-03 01:42:17 UTC
Comment on attachment 8725 [details] [review]
Followup for current language call

() fixes it because _current_language is not a declared symbol, so perl treats it as a bareword, and strict barfs when compiling. _current_language() is a function call, so gets resolved at runtime (C and Java people hate that). C4::Templates::_current_language() exists, so it gets executed.

So if you had in C4::Templates (which I thoroughly not recommend)

sub _current_language () {
    return $_current_language;
}

C4::Templates::_current_language would have worked, () prototypes the function and makes it a symbol.

That's why people use constant;