d708255c7a
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> |
||
---|---|---|
.. | ||
AuthoritiesMarc | ||
Barcodes | ||
ClassSortRoutine | ||
Creators | ||
External | ||
Form | ||
Heading | ||
ILSDI | ||
Installer | ||
Labels | ||
Linker | ||
Members | ||
OAI | ||
Output | ||
Patroncards | ||
Reports | ||
Search | ||
Serials | ||
SIP | ||
Utils | ||
Accounts.pm | ||
Acquisition.pm | ||
Auth.pm | ||
Auth_cas_servers.yaml.sample | ||
Auth_with_cas.pm | ||
Auth_with_ldap.pm | ||
Auth_with_shibboleth.pm | ||
AuthoritiesMarc.pm | ||
BackgroundJob.pm | ||
Barcodes.pm | ||
Biblio.pm | ||
Bookseller.pm | ||
Boolean.pm | ||
Breeding.pm | ||
Budgets.pm | ||
Calendar.pm | ||
Charset.pm | ||
Circulation.pm | ||
ClassSortRoutine.pm | ||
ClassSource.pm | ||
Context.pm | ||
Contract.pm | ||
CourseReserves.pm | ||
Creators.pm | ||
Debug.pm | ||
Heading.pm | ||
HoldsQueue.pm | ||
HTML5Media.pm | ||
Images.pm | ||
ImportBatch.pm | ||
ImportExportFramework.pm | ||
InstallAuth.pm | ||
Installer.pm | ||
ItemCirculationAlertPreference.pm | ||
Items.pm | ||
Koha.pm | ||
Labels.pm | ||
Languages.pm | ||
Letters.pm | ||
Linker.pm | ||
Log.pm | ||
MarcModificationTemplates.pm | ||
Matcher.pm | ||
Members.pm | ||
Message.pm | ||
NewsChannels.pm | ||
Output.pm | ||
Overdues.pm | ||
Patroncards.pm | ||
Print.pm | ||
Record.pm | ||
Reports.pm | ||
Reserves.pm | ||
Ris.pm | ||
RotatingCollections.pm | ||
Scheduler.pm | ||
Scrubber.pm | ||
Search.pm | ||
Serials.pm | ||
Service.pm | ||
ShelfBrowser.pm | ||
SMS.pm | ||
SocialData.pm | ||
Stats.pm | ||
Suggestions.pm | ||
Tags.pm | ||
Templates.pm | ||
TmplToken.pm | ||
TmplTokenType.pm | ||
TTParser.pm | ||
UsageStats.pm | ||
XISBN.pm | ||
XSLT.pm |