|
Lines 30-40
Koha::Template::Plugin::I18N - Translate strings in templates
Link Here
|
| 30 |
|
30 |
|
| 31 |
=head1 SYNOPSIS |
31 |
=head1 SYNOPSIS |
| 32 |
|
32 |
|
|
|
33 |
[% PROCESS 'i18n.inc' %] |
| 34 |
|
| 35 |
. . . |
| 36 |
|
| 37 |
[% I18N.t("Hello!") %] |
| 38 |
[% I18N.tx("Hello {name}", { name = name }) %] |
| 39 |
[% I18N.tn("Hello friend", "Hello friends", count) %] |
| 40 |
[% I18N.tnx("Hello my {count} friend", "Hello my {count} friends", count, { count = count }) %] |
| 41 |
[% I18N.tp('verb', 'Item') # to order %] |
| 42 |
[% I18N.tnp('bibliographic material', "item", "items", count) %] |
| 43 |
[% I18N.tnpx('bibliographic material', "{count} item", "{count} items", count, { count = count }) %] |
| 44 |
|
| 33 |
Do not use this plugin directly. Add the following directive |
45 |
Do not use this plugin directly. Add the following directive |
| 34 |
|
46 |
|
| 35 |
[% PROCESS 'i18n.inc' %] |
47 |
[% PROCESS 'i18n.inc' %] |
| 36 |
|
48 |
|
| 37 |
and use the macros defined here |
49 |
and use the macros defined. |
|
|
50 |
|
| 51 |
See: https://wiki.koha-community.org/wiki/Internationalization,_plural_forms,_context,_and_more_(RFC) |
| 52 |
for further context. |
| 38 |
|
53 |
|
| 39 |
=head1 METHODS |
54 |
=head1 METHODS |
| 40 |
|
55 |
|
|
Lines 42-47
and use the macros defined here
Link Here
|
| 42 |
|
57 |
|
| 43 |
[% I18N.t("hello") %] |
58 |
[% I18N.t("hello") %] |
| 44 |
|
59 |
|
|
|
60 |
Translate - The simplest type of translatable string where |
| 61 |
there are no variables and not pluralisations to consider. |
| 62 |
|
| 45 |
=cut |
63 |
=cut |
| 46 |
|
64 |
|
| 47 |
sub t { |
65 |
sub t { |
|
Lines 53-58
sub t {
Link Here
|
| 53 |
|
71 |
|
| 54 |
[% I18N.tx("hello {name}", { name = name }) %] |
72 |
[% I18N.tx("hello {name}", { name = name }) %] |
| 55 |
|
73 |
|
|
|
74 |
Translate with variable - A translatable string that |
| 75 |
includes a variable |
| 76 |
|
| 56 |
=cut |
77 |
=cut |
| 57 |
|
78 |
|
| 58 |
sub tx { |
79 |
sub tx { |
|
Lines 64-69
sub tx {
Link Here
|
| 64 |
|
85 |
|
| 65 |
[% I18N.tn("item", "items", count) %] |
86 |
[% I18N.tn("item", "items", count) %] |
| 66 |
|
87 |
|
|
|
88 |
Translate with plural - A translatable string that needs |
| 89 |
singular and plural forms |
| 90 |
|
| 67 |
=cut |
91 |
=cut |
| 68 |
|
92 |
|
| 69 |
sub tn { |
93 |
sub tn { |
|
Lines 75-80
sub tn {
Link Here
|
| 75 |
|
99 |
|
| 76 |
[% I18N.tnx("{count} item", "{count} items", count, { count = count }) %] |
100 |
[% I18N.tnx("{count} item", "{count} items", count, { count = count }) %] |
| 77 |
|
101 |
|
|
|
102 |
Translate with plural and variable - A translatable string |
| 103 |
that needs singular and plural forms and includes a variable |
| 104 |
|
| 78 |
=cut |
105 |
=cut |
| 79 |
|
106 |
|
| 80 |
sub tnx { |
107 |
sub tnx { |
|
Lines 97-102
sub txn {
Link Here
|
| 97 |
|
124 |
|
| 98 |
[% I18N.tp("context", "hello") %] |
125 |
[% I18N.tp("context", "hello") %] |
| 99 |
|
126 |
|
|
|
127 |
Translate with context - A translatable string where a |
| 128 |
context hint would be helpful to translators. |
| 129 |
|
| 130 |
An example would be where in english a single word may be |
| 131 |
be used as both a verb and a noun. You may want to add a |
| 132 |
note to distinguish this particular use case so translators |
| 133 |
can understand the context correctly. |
| 134 |
|
| 100 |
=cut |
135 |
=cut |
| 101 |
|
136 |
|
| 102 |
sub tp { |
137 |
sub tp { |
|
Lines 108-113
sub tp {
Link Here
|
| 108 |
|
143 |
|
| 109 |
[% I18N.tpx("context", "hello {name}", { name = name }) %] |
144 |
[% I18N.tpx("context", "hello {name}", { name = name }) %] |
| 110 |
|
145 |
|
|
|
146 |
Translate with context and variable - A translatable string |
| 147 |
that needs both a contextual hint and includes a variable. |
| 148 |
|
| 111 |
=cut |
149 |
=cut |
| 112 |
|
150 |
|
| 113 |
sub tpx { |
151 |
sub tpx { |
|
Lines 119-124
sub tpx {
Link Here
|
| 119 |
|
157 |
|
| 120 |
[% I18N.tnp("context", "item", "items", count) %] |
158 |
[% I18N.tnp("context", "item", "items", count) %] |
| 121 |
|
159 |
|
|
|
160 |
Translate with context and plural - A translatable string |
| 161 |
that needs both a contextual hints and singular and plural |
| 162 |
forms. |
| 163 |
|
| 122 |
=cut |
164 |
=cut |
| 123 |
|
165 |
|
| 124 |
sub tnp { |
166 |
sub tnp { |
|
Lines 130-135
sub tnp {
Link Here
|
| 130 |
|
172 |
|
| 131 |
[% I18N.tnpx("context", "{count} item", "{count} items", count, { count = count }) %] |
173 |
[% I18N.tnpx("context", "{count} item", "{count} items", count, { count = count }) %] |
| 132 |
|
174 |
|
|
|
175 |
Translate with context, plural and variables - A translatable |
| 176 |
string that needs contextual hints, singular and plural forms |
| 177 |
and also includes variables. |
| 178 |
|
| 133 |
=cut |
179 |
=cut |
| 134 |
|
180 |
|
| 135 |
sub tnpx { |
181 |
sub tnpx { |
| 136 |
- |
|
|