[Bug 36357] New: Add Template::Toolkit filters for internationalization (I18N)
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Bug ID: 36357 Summary: Add Template::Toolkit filters for internationalization (I18N) Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: ASSIGNED Severity: enhancement Priority: P5 - low Component: I18N/L10N Assignee: julian.maurice@biblibre.com Reporter: julian.maurice@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: frederic@tamil.fr, jonathan.druart@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #1 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 163380 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163380&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 36927) * 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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163380|0 |1 is obsolete| | --- Comment #2 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 163381 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163381&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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=36297 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163381|0 |1 is obsolete| | --- Comment #3 from Kyle M Hall <kyle@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@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #4 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 163522 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163522&action=edit Bug 36357: Tidy xgettext-tt2.t Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #5 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 163523 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163523&action=edit Bug 36357: Tidy I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 163524 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163524&action=edit Bug 36357: Add POD to Filters/I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA --- Comment #7 from Kyle M Hall <kyle@bywatersolutions.com> --- Getting Can't locate object method "new" via package "Template::Filters" (perhaps you forgot to load "Template::Filters"?) at /kohadevbox/koha/C4/Templates.pm line 74 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #8 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Kyle M Hall from comment #7)
Getting Can't locate object method "new" via package "Template::Filters" (perhaps you forgot to load "Template::Filters"?) at /kohadevbox/koha/C4/Templates.pm line 74
How do you get that ? I can't reproduce -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #9 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 163597 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163597&action=edit Bug 36357: Fix Template::Filters error Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #10 from Kyle M Hall <kyle@bywatersolutions.com> --- (In reply to Julian Maurice from comment #8)
(In reply to Kyle M Hall from comment #7)
Getting Can't locate object method "new" via package "Template::Filters" (perhaps you forgot to load "Template::Filters"?) at /kohadevbox/koha/C4/Templates.pm line 74
How do you get that ? I can't reproduce
Odd. I was able to fix the error by adding "use Template::Filters" to Templates.pm! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163521|0 |1 is obsolete| | --- Comment #11 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 168955 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168955&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@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163522|0 |1 is obsolete| | --- Comment #12 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 168956 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168956&action=edit Bug 36357: Tidy xgettext-tt2.t Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163523|0 |1 is obsolete| | --- Comment #13 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 168957 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168957&action=edit Bug 36357: Tidy I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163524|0 |1 is obsolete| | --- Comment #14 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 168958 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168958&action=edit Bug 36357: Add POD to Filters/I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #163597|0 |1 is obsolete| | --- Comment #15 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 168959 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168959&action=edit Bug 36357: Fix Template::Filters error Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA CC| |victor@tuxayo.net --- Comment #16 from Victor Grousset/tuxayo <victor@tuxayo.net> --- What's the reason to choose `require Koha::Template::Filters::I18N;` vs `use`? See https://wiki.koha-community.org/wiki/Coding_Guidelines#PERL31:_Prefer_.22use... ---- typos found: «Usesdf different» «Instanticate» --- Besides that, all seems to comply with coding guidelines :) Additional testing was done to double check the plural and single cases. To complement the test plan, I tested in the OPAC instead of staff interface. I don't see what else would be missing from test plan. I don't know enough on the functional side and about eventual unwanted side effects but at least here is a partial QA on the boring steps ^^ -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #17 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 168962 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168962&action=edit Bug 36357: Fix typos -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #18 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 168963 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168963&action=edit Bug 36357: Use "use" instead of "require" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #19 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Victor Grousset/tuxayo from comment #16)
What's the reason to choose `require Koha::Template::Filters::I18N;` vs `use`? It was only to avoid loading the module when not needed. I changed it since it isn't allowed by the new guideline.
Thanks for the review -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #20 from Victor Grousset/tuxayo <victor@tuxayo.net> ---
It was only to avoid loading the module when not needed. I changed it since it isn't allowed by the new guideline.
If the loading when not needed is heavy enough, there would be a case to use require. Anyway, thanks for the fixes :) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #21 from Jonathan Druart <jonathan.druart@gmail.com> --- To be honest I would prefer to have only one solution. If we decide to move to this one, then adjust the previous occurrences. Would you agree with that, Julian? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #22 from Jonathan Druart <jonathan.druart@gmail.com> --- And we will need to adjust the wiki page: https://wiki.koha-community.org/wiki/Internationalization,_plural_forms,_con... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #23 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Jonathan Druart from comment #21)
To be honest I would prefer to have only one solution. If we decide to move to this one, then adjust the previous occurrences. Would you agree with that, Julian? Then we would need to also add the "context variants" (see commit message). Not a problem, just a little more work.
I'm not sure I completely agree though. Functions can be useful where filters cannot be easily used. But we can drop the MACROs that pollute global namespace and keep functions under the i18n namespace. Filters would be always available (so they would become naturally the preferred method), and, only when needed, we could USE I18N and its functions. It's not a strong opinion. If more people believe they should be removed, I'm fine with it. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=38618 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Patch doesn't apply -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168955|0 |1 is obsolete| | --- Comment #24 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180376 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180376&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@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168956|0 |1 is obsolete| | --- Comment #25 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180377 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180377&action=edit Bug 36357: Tidy xgettext-tt2.t Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168957|0 |1 is obsolete| | --- Comment #26 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180378 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180378&action=edit Bug 36357: Tidy I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168958|0 |1 is obsolete| | --- Comment #27 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180379 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180379&action=edit Bug 36357: Add POD to Filters/I18N.pm Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168959|0 |1 is obsolete| | --- Comment #28 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180380 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180380&action=edit Bug 36357: Fix Template::Filters error Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168962|0 |1 is obsolete| | --- Comment #29 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180381 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180381&action=edit Bug 36357: Fix typos -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #168963|0 |1 is obsolete| | --- Comment #30 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 180382 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180382&action=edit Bug 36357: Use "use" instead of "require" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff --- Comment #31 from Julian Maurice <julian.maurice@biblibre.com> --- Patches rebased on main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Status|Needs Signoff |Failed QA --- Comment #32 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- The QA tool complains: [FAIL] C4/Templates.pm FAIL tidiness File is not tidy, please run `perl misc/devel/tidy.pl C4/Templates.pm` [PASS] Koha/Template/Filters/I18N.pm [FAIL] t/db_dependent/misc/translator/sample.tt FAIL filters missing_filter at line 38 ([% 'with filter' | t %]) missing_filter at line 40 ([% 'filter singular' | tn('filter plural', 2) %]) FAIL valid_template t: filter not found -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180376|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180377|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180378|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180379|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180380|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180381|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180382|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #33 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 196175 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196175&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@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #34 from Julian Maurice <julian.maurice@biblibre.com> --- Patches squashed and rebased + tidy fix qa script still complains about "t: filter not found" but that can be ignored. qa script will need to be updated when this patch is pushed -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196175|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36357 --- Comment #35 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 196198 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196198&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@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org