Koha-clms/Koha/Plugins
Nicolas Legrand 34c07a58f8 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.

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
2020-05-11 22:01:55 +00:00
..
Base.pm Bug 25099: Sending a LANG variable to plug-in template 2020-05-11 22:01:55 +00:00
Handler.pm Bug 21073: (QA follow-up) Don't call -> twice! 2019-06-18 17:30:39 +01:00
Method.pm Bug 21073: Add new table, schema and classes 2019-06-18 17:29:13 +01:00
Methods.pm Bug 21073: (QA follow-up) Fix typo in class name 2019-06-19 09:55:31 +01:00
Tab.pm Bug 23050: (QA follow-up) Add Koha::Plugins::Tab class 2019-11-05 08:13:59 +00:00