[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
Wed Mar 20 13:10:57 CET 2024
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357
Kyle M Hall <kyle at bywatersolutions.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #163381|0 |1
is obsolete| |
--- Comment #3 from Kyle M Hall <kyle at bywatersolutions.com> ---
Created attachment 163521
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163521&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
Signed-off-by: Kyle M Hall <kyle at bywatersolutions.com>
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list