Bugzilla – Attachment 81157 Details for
Bug 15395
Internationalization: plural forms, context, and more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15395: Make QA test script happy
Bug-15395-Make-QA-test-script-happy.patch (text/plain), 8.82 KB, created by
Julian Maurice
on 2018-10-25 13:23:42 UTC
(
hide
)
Description:
Bug 15395: Make QA test script happy
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2018-10-25 13:23:42 UTC
Size:
8.82 KB
patch
obsolete
>From fece32216e9d31aa5a0cdac99d3621473f7b4373 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 25 Oct 2018 14:06:03 +0200 >Subject: [PATCH] Bug 15395: Make QA test script happy > >It is not totally happy because of the template file used in tests. >It has line breaks inside TT directives and QA test script complains >because line breaks in TT directives confuse the current translatable >strings extractor. >However this patchset (along with bug 20988) will hopefully make the >current extractor obsolete and thus make the 'no-line-breaks' rule >useless >--- > Koha/Template/Plugin/I18N.pm | 68 +++++++++++++++++++ > .../intranet-tmpl/prog/en/includes/i18n.inc | 59 ++++++++-------- > .../opac-tmpl/bootstrap/en/includes/i18n.inc | 59 ++++++++-------- > t/LangInstaller/templates/simple.tt | 22 +++--- > 4 files changed, 137 insertions(+), 71 deletions(-) > >diff --git a/Koha/Template/Plugin/I18N.pm b/Koha/Template/Plugin/I18N.pm >index 8c95ea6d72..976c13927f 100644 >--- a/Koha/Template/Plugin/I18N.pm >+++ b/Koha/Template/Plugin/I18N.pm >@@ -24,46 +24,114 @@ use base qw( Template::Plugin ); > use C4::Context; > use Koha::I18N; > >+=head1 NAME >+ >+Koha::Template::Plugin::I18N - Translate strings in templates >+ >+=head1 SYNOPSIS >+ >+Do not use this plugin directly. Add the following directive >+ >+ [% PROCESS 'i18n.inc' %] >+ >+and use the macros defined here >+ >+=head1 METHODS >+ >+=head2 t >+ >+ [% I18N.t("hello") %] >+ >+=cut >+ > sub t { > my ($self, $msgid) = @_; > return __($msgid); > } > >+=head2 tx >+ >+ [% I18N.tx("hello {name}", { name = name }) %] >+ >+=cut >+ > sub tx { > my ($self, $msgid, $vars) = @_; > return __x($msgid, %$vars); > } > >+=head2 tn >+ >+ [% I18N.tn("item", "items", count) %] >+ >+=cut >+ > sub tn { > my ($self, $msgid, $msgid_plural, $count) = @_; > return __n($msgid, $msgid_plural, $count); > } > >+=head2 tnx >+ >+ [% I18N.tnx("{count} item", "{count} items", count, { count = count }) %] >+ >+=cut >+ > sub tnx { > my ($self, $msgid, $msgid_plural, $count, $vars) = @_; > return __nx($msgid, $msgid_plural, $count, %$vars); > } > >+=head2 txn >+ >+Alias of tnx >+ >+=cut >+ > sub txn { > my ($self, $msgid, $msgid_plural, $count, $vars) = @_; > return __xn($msgid, $msgid_plural, $count, %$vars); > } > >+=head2 tp >+ >+ [% I18N.tp("context", "hello") %] >+ >+=cut >+ > sub tp { > my ($self, $msgctxt, $msgid) = @_; > return __p($msgctxt, $msgid); > } > >+=head2 tpx >+ >+ [% I18N.tpx("context", "hello {name}", { name = name }) %] >+ >+=cut >+ > sub tpx { > my ($self, $msgctxt, $msgid, $vars) = @_; > return __px($msgctxt, $msgid, %$vars); > } > >+=head2 tnp >+ >+ [% I18N.tnp("context", "item", "items") %] >+ >+=cut >+ > sub tnp { > my ($self, $msgctxt, $msgid, $msgid_plural, $count) = @_; > return __np($msgctxt, $msgid, $msgid_plural, $count); > } > >+=head2 tnpx >+ >+ [% I18N.tnpx("context", "{count} item", "{count} items", { count = count }) %] >+ >+=cut >+ > sub tnpx { > my ($self, $msgctxt, $msgid, $msgid_plural, $count, $vars) = @_; > return __np($msgctxt, $msgid, $msgid_plural, $count, %$vars); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/i18n.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/i18n.inc >index 4b5da9231b..3ad521e843 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/i18n.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/i18n.inc >@@ -1,39 +1,38 @@ >-[% >- USE I18N; >+[% USE I18N %] >+[% USE raw %] > >- MACRO t(msgid) BLOCK; >- I18N.t(msgid); >- END; >+[% MACRO t(msgid) BLOCK %] >+ [% I18N.t(msgid) | $raw %] >+[% END %] > >- MACRO tx(msgid, vars) BLOCK; >- I18N.tx(msgid, vars); >- END; >+[% MACRO tx(msgid, vars) BLOCK %] >+ [% I18N.tx(msgid, vars) | $raw %] >+[% END %] > >- MACRO tn(msgid, msgid_plural, count) BLOCK; >- I18N.tn(msgid, msgid_plural, count); >- END; >+[% MACRO tn(msgid, msgid_plural, count) BLOCK %] >+ [% I18N.tn(msgid, msgid_plural, count) | $raw %] >+[% END %] > >- MACRO tnx(msgid, msgid_plural, count, vars) BLOCK; >- I18N.tnx(msgid, msgid_plural, count, vars); >- END; >+[% MACRO tnx(msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.tnx(msgid, msgid_plural, count, vars) | $raw %] >+[% END %] > >- MACRO txn(msgid, msgid_plural, count, vars) BLOCK; >- I18N.txn(msgid, msgid_plural, count, vars); >- END; >+[% MACRO txn(msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.txn(msgid, msgid_plural, count, vars) | $raw %] >+[% END %] > >- MACRO tp(msgctxt, msgid) BLOCK; >- I18N.tp(msgctxt, msgid); >- END; >+[% MACRO tp(msgctxt, msgid) BLOCK %] >+ [% I18N.tp(msgctxt, msgid) | $raw %] >+[% END %] > >- MACRO tpx(msgctxt, msgid, vars) BLOCK; >- I18N.tpx(msgctxt, msgid, vars); >- END; >+[% MACRO tpx(msgctxt, msgid, vars) BLOCK %] >+ [% I18N.tpx(msgctxt, msgid, vars) | $raw %] >+[% END %] > >- MACRO tnp(msgctxt, msgid, msgid_plural, count) BLOCK; >- I18N.tnp(msgctxt, msgid, msgid_plural, count); >- END; >+[% MACRO tnp(msgctxt, msgid, msgid_plural, count) BLOCK %] >+ [% I18N.tnp(msgctxt, msgid, msgid_plural, count) | $raw %] >+[% END %] > >- MACRO tnpx(msgctxt, msgid, msgid_plural, count, vars) BLOCK; >- I18N.tnpx(msgctxt, msgid, msgid_plural, count, vars); >- END; >-%] >+[% MACRO tnpx(msgctxt, msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.tnpx(msgctxt, msgid, msgid_plural, count, vars) | $raw %] >+[% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/i18n.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/i18n.inc >index 4b5da9231b..3ad521e843 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/i18n.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/i18n.inc >@@ -1,39 +1,38 @@ >-[% >- USE I18N; >+[% USE I18N %] >+[% USE raw %] > >- MACRO t(msgid) BLOCK; >- I18N.t(msgid); >- END; >+[% MACRO t(msgid) BLOCK %] >+ [% I18N.t(msgid) | $raw %] >+[% END %] > >- MACRO tx(msgid, vars) BLOCK; >- I18N.tx(msgid, vars); >- END; >+[% MACRO tx(msgid, vars) BLOCK %] >+ [% I18N.tx(msgid, vars) | $raw %] >+[% END %] > >- MACRO tn(msgid, msgid_plural, count) BLOCK; >- I18N.tn(msgid, msgid_plural, count); >- END; >+[% MACRO tn(msgid, msgid_plural, count) BLOCK %] >+ [% I18N.tn(msgid, msgid_plural, count) | $raw %] >+[% END %] > >- MACRO tnx(msgid, msgid_plural, count, vars) BLOCK; >- I18N.tnx(msgid, msgid_plural, count, vars); >- END; >+[% MACRO tnx(msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.tnx(msgid, msgid_plural, count, vars) | $raw %] >+[% END %] > >- MACRO txn(msgid, msgid_plural, count, vars) BLOCK; >- I18N.txn(msgid, msgid_plural, count, vars); >- END; >+[% MACRO txn(msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.txn(msgid, msgid_plural, count, vars) | $raw %] >+[% END %] > >- MACRO tp(msgctxt, msgid) BLOCK; >- I18N.tp(msgctxt, msgid); >- END; >+[% MACRO tp(msgctxt, msgid) BLOCK %] >+ [% I18N.tp(msgctxt, msgid) | $raw %] >+[% END %] > >- MACRO tpx(msgctxt, msgid, vars) BLOCK; >- I18N.tpx(msgctxt, msgid, vars); >- END; >+[% MACRO tpx(msgctxt, msgid, vars) BLOCK %] >+ [% I18N.tpx(msgctxt, msgid, vars) | $raw %] >+[% END %] > >- MACRO tnp(msgctxt, msgid, msgid_plural, count) BLOCK; >- I18N.tnp(msgctxt, msgid, msgid_plural, count); >- END; >+[% MACRO tnp(msgctxt, msgid, msgid_plural, count) BLOCK %] >+ [% I18N.tnp(msgctxt, msgid, msgid_plural, count) | $raw %] >+[% END %] > >- MACRO tnpx(msgctxt, msgid, msgid_plural, count, vars) BLOCK; >- I18N.tnpx(msgctxt, msgid, msgid_plural, count, vars); >- END; >-%] >+[% MACRO tnpx(msgctxt, msgid, msgid_plural, count, vars) BLOCK %] >+ [% I18N.tnpx(msgctxt, msgid, msgid_plural, count, vars) | $raw %] >+[% END %] >diff --git a/t/LangInstaller/templates/simple.tt b/t/LangInstaller/templates/simple.tt >index 5d8fb1084b..4b95636526 100644 >--- a/t/LangInstaller/templates/simple.tt >+++ b/t/LangInstaller/templates/simple.tt >@@ -1,11 +1,11 @@ >-[% t('hello') %] >-[% tx('hello {name}', { name = 'Bob' }) %] >-[% tn('item', 'items', count) %] >-[% tnx('{count} item', '{count} items', count, { count = count }) %] >-[% tp('context', 'hello') %] >-[% tpx('context', 'hello {name}', { name = 'Bob' }) %] >-[% tnp('context', 'item', 'items', count) %] >-[% tnpx('context', '{count} item', '{count} items', count, { count = count }) %] >+[% t('hello') | $raw %] >+[% tx('hello {name}', { name = 'Bob' }) | $raw %] >+[% tn('item', 'items', count) | $raw %] >+[% tnx('{count} item', '{count} items', count, { count = count }) | $raw %] >+[% tp('context', 'hello') | $raw %] >+[% tpx('context', 'hello {name}', { name = 'Bob' }) | $raw %] >+[% tnp('context', 'item', 'items', count) | $raw %] >+[% tnpx('context', '{count} item', '{count} items', count, { count = count }) | $raw %] > > [% # it also works on multiple lines > tnpx ( >@@ -16,13 +16,13 @@ > { > count = count, > } >- ) >+ ) | $raw > %] > > [% # and t* calls can be nested > tx('status is {status}', { > status = active ? t('active') : t('inactive') >- }) >+ }) | $raw > %] > > [%# but a TT comment won't get picked >@@ -30,5 +30,5 @@ > %] > > [% BLOCK %] >- [% t('Inside block') %] >+ [% t('Inside block') | $raw %] > [% END %] >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15395
:
45797
|
45798
|
45799
|
46337
|
50023
|
50024
|
50025
|
50026
|
61873
|
61874
|
61875
|
61876
|
61934
|
61935
|
61977
|
62008
|
62041
|
62326
|
62327
|
62328
|
62329
|
62330
|
62331
|
62332
|
62333
|
62335
|
62709
|
65894
|
70974
|
70975
|
70976
|
71940
|
71941
|
71942
|
71943
|
71944
|
71945
|
71946
|
71947
|
71948
|
71949
|
71950
|
71951
|
71952
|
73901
|
73902
|
73903
|
73904
|
73905
|
73906
|
73907
|
73908
|
73909
|
73910
|
73911
|
73912
|
73913
|
76328
|
76329
|
76330
|
77475
|
77476
|
81152
|
81153
|
81154
|
81155
|
81156
|
81157
|
81158
|
81159
|
81167
|
81734
|
81735
|
81736
|
81737
|
81738
|
81739
|
81741
|
81742
|
81743