Bugzilla – Attachment 102644 Details for
Bug 25099
Sending a LANG variable to plug-in template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25099: Add lang from cookie to plugins template params
Bug-25099-Add-lang-from-cookie-to-plugins-template.patch (text/plain), 2.03 KB, created by
Nicolas Legrand
on 2020-04-09 15:13:02 UTC
(
hide
)
Description:
Bug 25099: Add lang from cookie to plugins template params
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2020-04-09 15:13:02 UTC
Size:
2.03 KB
patch
obsolete
>From a1813ad587ae17a83f5952f75e9c0359fa8bda6b Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Thu, 9 Apr 2020 16:50:55 +0200 >Subject: [PATCH] Bug 25099: Add lang from cookie to plugins template params >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >To make internationalised plugins, it may be useful to get the >KohaOpacLanguage from Koha cookie. This patch adds the value of >$cgi->cookie('KohaOpacLanguage') to a LANG variable which is sent to >the template plugin. > >In your plugin, you can add a i18n directory containing >lang[-DIALECT].inc files with a TOKENS hash like this: > > [% > TOKENS = { > PLUGIN_NAME = "Mannequin" > PRESENTATION = "Voici un example d'outil." > CLICK_ME = "Cliquez moi !" > } > %] > >The plugin template can then include such a lang[-DIALECT].inc with a >hash containing all the plugin strings: > > [% TRY %] > [% PROCESS "$PLUGIN_DIR/i18n/${LANG}.inc" %] > [% CATCH %] > [% PROCESS "$PLUGIN_DIR/i18n/default.inc" %] > [% END %] > >The strings are then printed in the template with something like: > > [% TOKENS.PRESENTATION %] > >Test plan: > >1. apply patch >2. install, enable and run BULAC Mannequin plugin >3. it should print stuff in english by default >4. install french French (fr-FR) >5. change you Koha lang to French >6. run again the plugin >7. ho là là ! French! >--- > Koha/Plugins/Base.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/Koha/Plugins/Base.pm b/Koha/Plugins/Base.pm >index 6a723c0..60febf5 100644 >--- a/Koha/Plugins/Base.pm >+++ b/Koha/Plugins/Base.pm >@@ -163,12 +163,12 @@ sub get_template { > authnotrequired => 1, > } > ); >- > $template->param( > CLASS => $self->{'class'}, > METHOD => scalar $self->{'cgi'}->param('method'), > PLUGIN_PATH => $self->get_plugin_http_path(), > PLUGIN_DIR => $self->get_plugin_dir(), >+ LANG => $self->{'cgi'}->cookie('KohaOpacLanguage') || 'en' > ); > > return $template; >-- >2.1.4
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 25099
:
102643
|
102644
|
104309
|
104317
|
104374