[Koha-bugs] [Bug 36357] Add Template::Toolkit filters for internationalization (I18N)

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Mar 19 09:28:42 CET 2024


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

Julian Maurice <julian.maurice at biblibre.com> changed:

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

--- Comment #2 from Julian Maurice <julian.maurice at biblibre.com> ---
Created attachment 163381
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163381&action=edit
Bug 36357: Add Template::Toolkit filters for internationalization (I18N)

This patch makes it possible to write in templates the following:

[% 'simple text' | t %]
[% 'text with {var}' | tx(var = 'value') %]
[% 'singular' | tn('plural', count) %]
[% 'singular with {var}' | tnx('plural with {var}', cnt, var = 'val') %]

These filters are an alternative to the macros defined in i18n.inc.
Some advantages:
* They do not conflict with variables (see bug 36297)
* They are always defined (no need to USE a plugin or PROCESS a file)

i18n functions that takes a context argument (tp, tpx, tnp, tnpx)
are deliberately not defined as filters.
Because context is the first argument, this would require writing:
  [% 'context' | tp('message') %]
Whereas we'd prefer to write:
  [% 'message' | tp('context') %]
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

Test plan:
1. Find a template file that you can edit and where you can easily see
   the changes (for instance intranet-main.tt)
2. Add the following code:
   [% 'simple text' | t %]
   [% 'text with {var}' | tx(var = 'value') %]
   [% 'singular' | tn('plural', 1) %]
   [% 'singular with {var}' | tnx('plural with {var}', 2, var = 'val') %]
3. Run misc/translator/translate update fr-FR
4. Open misc/translator/po/fr-FR-messages.po, make sure you find those 4
   new strings. Translate them.
5. Run misc/translator/translate install fr-FR
6. Restart Koha
7. Change the language in the interface. Verify that the strings are
   translated

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


More information about the Koha-bugs mailing list