[Koha-bugs] [Bug 25099] Sending a LANG variable to plug-in template

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue May 5 16:34:14 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25099

Martin Renvoize <martin.renvoize at ptfs-europe.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #104317|0                           |1
        is obsolete|                            |

--- Comment #12 from Martin Renvoize <martin.renvoize at ptfs-europe.com> ---
Created attachment 104374
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=104374&action=edit
Bug 25099: Sending a LANG variable to plug-in template

To make internationalised plug-ins, it may be useful to get the lang
from C4::Languages::getlanguage. This patch adds
C4::Languages::getlanguage result 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!

Thanks to Tomàs Cohen and his pay via paypal plug-in from which most
ideas in this patch are taken.

Signed-off-by: Victor Grousset/tuxayo <victor at tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize at ptfs-europe.com>

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list