From efd09b4a5245c92c748ffa561cefb6ace5fd697e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 20 Mar 2024 12:08:18 +0000 Subject: [PATCH] Bug 36357: Add POD to Filters/I18N.pm Signed-off-by: Kyle M Hall Signed-off-by: Victor Grousset/tuxayo --- Koha/Template/Filters/I18N.pm | 63 ++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/Koha/Template/Filters/I18N.pm b/Koha/Template/Filters/I18N.pm index 9f6a5806c8..5cface7865 100644 --- a/Koha/Template/Filters/I18N.pm +++ b/Koha/Template/Filters/I18N.pm @@ -23,9 +23,17 @@ our $DYNAMIC_FILTERS = { # There are two ways to fix this: # 1. Change the order of arguments in Koha::Template::Plugin::I18N and # change the -k options in xgettext-tt2 (the msgid must be first), or - # 2. Use different keywords, and add them as -k options in xgettext-tt2 + # 2. Usesdf different keywords, and add them as -k options in xgettext-tt2 }; +=head1 METHODS + +=head2 fetch + +Instanticate or return a ref to the filter subroutines + +=cut + sub fetch { my ( $self, $name, $args, $context ) = @_; @@ -38,19 +46,44 @@ sub fetch { return ( undef, Template::Constants::STATUS_DECLINED ); } -# This sub is never called in theory as Template::Filters::store is called -# first and accept all filters. -# We declare it anyway, just in case the order of filter providers is changed +=head2 store + +This sub is never called in theory as Template::Filters::store is called +first and accept all filters. +We declare it anyway, just in case the order of filter providers is changed + +=cut + sub store { return ( undef, Template::Constants::STATUS_DECLINED ); } +=head2 t + + [% var | t %] + +Translate - The simplest type of translatable string where +there are no variables and not pluralisations to consider. + +=cut + sub t { my ($msgid) = @_; return __($msgid); } +=head2 tx_factory + + [% var | tx("hello {name}", { name = name }) %] + +Mapped to the tx filter. + +Translate with variable - A translatable string that +includes a variable + +=cut + sub tx_factory { my ( $context, $vars ) = @_; @@ -61,6 +94,17 @@ sub tx_factory { } } +=head2 tn_factory + + [% var | tn("item", "items", count) %] + +Mapped to the tn filter + +Translate with plural - A translatable string that needs +singular and plural forms + +=cut + sub tn_factory { my ( $context, $msgid_plural, $count ) = @_; @@ -71,6 +115,17 @@ sub tn_factory { } } +=head2 tnx_factory + + [% var | tnx("{count} item", "{count} items", count, { count = count }) %] + +Mapped to the tnx filter + +Translate with plural and variable - A translatable string +that needs singular and plural forms and includes a variable + +=cut + sub tnx_factory { my ( $context, $msgid_plural, $count, $vars ) = @_; -- 2.45.2