Koha/koha-tmpl/intranet-tmpl/prog/en/includes
Julian Maurice d708255c7a Bug 15395: Allow correct handling of plural translation
Locale::Maketext does not allow correct handling of plural translation
for languages that have more than one plural forms.
Locale::Messages does.

So Koha::I18N is now a wrapper around Locale::Messages, just like
Locale::TextDomain, and export the same symbols as Locale::TextDomain.
You can refer to documentation of Locale::TextDomain to know how to use
exported subroutines.

Example usage:
  __("Hi")
  __x("Hi {name}", name => 'Bob')
  __n("item", "items", $num_items)
  __nx("one item", "{count} items", $num_items, count => $num_items)
  __p("Bibliographic record", "item")

This patch also brings Koha::I18N power to Template::Toolkit templates
by adding a TT plugin.
This plugin can be used like this:

[%# USE the plugin and define some macros %]
[% PROCESS 'i18n.inc' %]

[%# tn is the equivalent of __n %]
[%# macro names can't start with underscore, t is for "translate" %]
[% tn('item', 'items', num_items) %]
Extraction of strings from templates is a bit complicated and use
Template::Parser and PPI. Template is compiled into Perl code and then
analyzed by PPI. It is slow, but should be correct even with complex
constructions.

Remove dependency to Locale::Maketext and Locale::Maketext::Lexicon
Add dependency to Locale::Messages and PPI

Test plan for translation in Perl code:
1. Open a .pl script or .pm module with your favorite text editor
2. Add 'use Koha::I18N;' in the beginning of file
3. Use one of the subroutines exported by Koha::I18N and be sure to have
   a way to visualize the result (pass result to the template for
   example, or simply warn and watch the log file)
4. cd misc/translator && ./translate update fr-FR # try other languages
5. Open misc/translator/po/fr-FR-messages.po and translate your
   string(s)
   You may need to change the "Plural-Forms" header. See
   https://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html
6. ./translate install fr-FR
7. Use your web browser to go to the page that should display the
   translation, change language and verify the translation is correct
8. prove t/Koha/I18N.t

Test plan for translation in templates:
1. Open a template file (.tt or .inc) with your favorite text editor
2. Add the PROCESS directive mentioned above in the beginning of file
3. Use one of the t* macros defined in i18n.inc. They are used like
   their "__" equivalent, with one difference: the 'x' variants take a
   hashref instead of a hash as last parameter
4. cd misc/translator && ./translate update fr-FR
5. Open misc/translator/po/fr-FR-messages.po and translate your
   string(s)
6. ./translate install fr-FR
7. Use your web browser to go to the page that should display the
   translation, change language and verify the translation is
   correct

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-08 15:55:50 +00:00
..
catalogue Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
csv_headers Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
modals Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
str Bug 21068: Remove NorwegianPatronDB related code 2018-08-30 13:40:29 +00:00
virtualshelves/merge Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
accounts.inc Bug 21715: Ease translation of account and account offset type descriptions 2018-11-08 02:18:47 +00:00
acquisitions-add-to-basket.inc Bug 15184: Add the ability to duplicate existing order lines 2018-11-08 15:52:57 +00:00
acquisitions-menu.inc Bug 11911: Add a separate permission for managing suggestions 2018-07-23 15:34:20 +00:00
acquisitions-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
acquisitions-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
additem.js.inc
admin-items-search-field-form.inc Bug 13618: remove wrong html filter in 'Item search fields' admin 2018-10-26 15:54:54 +00:00
admin-menu.inc Bug 14391: (follow-up) check for correct patron categories permission 2018-11-07 14:02:27 +00:00
adv-search.inc Bug 13272: (follow-up) add missing type="text" 2018-10-01 11:18:32 +00:00
auth-finder-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
authorities-search-results.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
authorities-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
authorities-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
authorities.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
authorities_js.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
av-build-dropbox.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
biblio-default-view.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
biblio-view-menu.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
blocked-fines.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
blocking_errors.inc Bug 15184: Add the ability to duplicate existing order lines 2018-11-08 15:52:57 +00:00
borrower_debarments.inc Bug 13272: (follow-up) fix concerns from comment #5 2018-10-01 11:18:31 +00:00
branch-selector.inc Bug 21669: Do not html filter TT assignement statements 2018-10-26 16:38:36 +00:00
browser-strings.inc
budgets-active-currency.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
budgets-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
budgets-admin-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
calendar.inc Bug 16754: Use validation plugin in budgets, planning, and contracts 2018-10-17 12:42:04 +00:00
cat-menu.inc
cat-search.inc Bug 13272: Adds type="text" to inputs missing it 2018-10-01 11:18:30 +00:00
cat-toolbar.inc Bug 20968: (RM follow-up) Add missing filter 2018-11-02 10:41:15 +00:00
catalog-strings.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
cataloging-search.inc Bug 13272: (follow-up) add missing type="text" 2018-10-01 11:18:32 +00:00
cateditor-ui.inc Bug 14786: Use MARC istead of ISO2709 everywhere 2018-10-17 13:55:19 +00:00
cateditor-widgets-marc21.inc Bug 19263: Rancor - 001 widget - changes to address QA issues 2018-10-27 13:26:09 +00:00
chart.inc Bug 17282: add template's variable filters 2018-10-01 13:56:36 +00:00
checkin-search.inc Bug 13272: (follow-up) add missing type="text" 2018-10-01 11:18:32 +00:00
checkouts-table-footer.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
checkouts-table.inc Bug 14786: Use MARC istead of ISO2709 everywhere 2018-10-17 13:55:19 +00:00
circ-menu.inc Bug 20312: Add missing filters 2018-11-08 15:52:55 +00:00
circ-nav.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
circ-patron-search-results.inc Bug 21703: Fix filter on dataurl variable to allow placing holds in staff again 2018-10-29 00:27:42 +00:00
circ-search.inc Bug 13272: Adds type="text" to inputs missing it 2018-10-01 11:18:30 +00:00
cities-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
columns_settings.inc Bug 21216: (follow-up) Exclude some columns from export 2018-10-24 13:38:49 +00:00
contracts-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
country-list.inc
currencies-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
datatables.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
date-format.inc
delimiter_text.inc
doc-head-close-receipt.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
doc-head-close.inc Bug 21352: Add missing USE statements 2018-10-03 17:45:58 +00:00
doc-head-open.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
empty_line.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
facets.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
filter-orders.inc Bug 15184: add missing filters 2018-11-08 15:52:58 +00:00
form-blocks.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
format_price.inc
greybox.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
guided-reports-view.inc
header.inc Bug 20312: (QA follow-up) Make display syspref driven 2018-11-08 15:38:20 +00:00
holds_table.inc Bug 21611: Fix priority dropdown for holds 2018-10-29 00:19:28 +00:00
home-search.inc Bug 13272: Adds type="text" to inputs missing it 2018-10-01 11:18:30 +00:00
html_helpers.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
i18n.inc Bug 15395: Allow correct handling of plural translation 2018-11-08 15:55:50 +00:00
ill-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
installer-doc-head-close.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
installer-strings.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
intranet-bottom.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
intranetstylesheet.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
js_includes.inc Bug 15734: Use To.json to filter audio alerts 2018-10-09 15:45:03 +00:00
labels-toolbar.inc
langmenu-staff-top.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
last-borrower.inc Bug 20312: Add a link to last consulted patron 2018-11-08 15:38:20 +00:00
letters-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-address-style-de.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-address-style-fr.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-address-style-us.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-contact-style-de.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-contact-style-fr.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-alt-contact-style-us.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-address-style-de.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-address-style-fr.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-address-style-us.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-alt-address-style-de.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-alt-address-style-fr.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-display-alt-address-style-us.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-main-address-style-de.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-main-address-style-fr.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
member-main-address-style-us.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
members-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
merge-record-strings.inc
merge-record.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
messaging-preference-form.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
noadd-warnings.inc
onboarding_messages.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
page-numbers.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
password_check.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
patron-article-requests.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
patron-search-box.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
patron-search.inc Bug 13272: Adds type="text" to inputs missing it 2018-10-01 11:18:30 +00:00
patron-title.inc Bug 21526: Remove duplicated USE raw statement 2018-10-26 17:09:58 +00:00
patron-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
patroncards-errors.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
patroncards-toolbar.inc
patrons-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
permissions.inc Bug 14391: (QA follow-up) Fix some typos 2018-11-07 12:29:32 +00:00
popup-bottom.inc Bug 13618: Manually replace missing .raw 2018-08-17 15:55:10 +00:00
prefs-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
prefs-menu.inc
quotes-toolbar.inc
quotes-upload-toolbar.inc
reports-menu.inc
reports-toolbar.inc Bug 17282: add template's variable filters 2018-10-01 13:56:36 +00:00
resort_form.inc
rotating-collections-toolbar.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
search_indexes.inc Bug 9968: Fix wrong index for Standard number in advanced and label search 2018-10-09 11:04:24 +00:00
select2.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
serials-menu.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
serials-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
serials-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
slip-print.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
stockrotation-toolbar.inc Bug 11897: (QA follow-up) Template filter fixes 2018-10-09 15:46:06 +00:00
strings.inc Bug 15494: Update display of renewal errors 2018-11-07 21:39:38 +00:00
subscriptions-search.inc
subtypes_unimarc.inc
suggestions-add-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
timepicker.inc
tools-item-action.inc
tools-menu.inc Bug 11897: Stockrotation 2018-10-09 15:46:05 +00:00
tools-nomatch-action.inc
tools-overlay-action.inc
validator-strings.inc
vendor-menu.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
virtualshelves-toolbar.inc Bug 21526: uri escape TT variables when used in 'a href' 2018-10-26 17:09:57 +00:00
waiting_holds.inc Bug 21628: (follow-up) Indentation and filter corrections 2018-11-08 02:18:47 +00:00
wysiwyg-systempreferences.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
xslt-handler.inc
z3950-admin-search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00
z3950_search.inc Bug 13618: Add html filters to all the variables 2018-08-17 15:55:05 +00:00