[Bug 11848] New: Make Koha::I18N easier to user
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bug ID: 11848 Summary: Make Koha::I18N easier to user 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 Depends on: 8044 Actually (with bug 8044), to translate a string in a Perl script or module you have to write: use CGI; use Koha::I18N; my $cgi = new CGI; my $lh = Koha::I18N->get_handle_from_context($cgi, 'intranet'); print $lh->maketext('my translatable text'); With the patches I'll submit, this will become: use Koha::I18N; print gettext('my translatable text'); -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #1 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 25664 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25664&action=edit Bug 11848: Move language detection function in C4::Languages and store interface (intranet, opac) in context to not have to pass it as parameter. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #2 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 25665 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25665&action=edit Bug 11848: Make Koha::I18N easier to use Instead of writing use CGI; use Koha::I18N; my $cgi = new CGI; my $lh = Koha::I18N->get_handle_from_context($cgi, 'intranet'); print $lh->maketext('my translatable text'); you can now write use Koha::I18N; print gettext('my translatable text'); -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff --- Comment #3 from Julian Maurice <julian.maurice@biblibre.com> --- Test plan (for developpers): 1/ Edit a Perl script, for example mainpage.pl 2/ add "use Koha::I18N;" to the top of file 3/ add a translatable message somewhere in the script (this have to be after the call to get_template_and_user). For example: warn gettext("This is a translated warning"); 4/ Create or update the PO files with misc/translator/translate create LANGCODE or misc/translator/translate update LANGCODE (LANGCODE should be enable in syspref 'languages') 5/ In misc/translator/po/LANGCODE-messages.po you should have your string, translate it (using a text editor or a PO file editor, make sure you don't have the "fuzzy" flag for this string). 6/ Go to mainpage.pl with active language being English with your browser and check your logs. You should see your string "This is a translated warning". 7/ Now change language to LANGCODE. Check your logs, you should have the string translated. Note: I chose to name the sub 'gettext' because it's the default keyword for xgettext for Perl. We can change it to whatever we want. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #4 from Julian Maurice <julian.maurice@biblibre.com> --- Note 2: The purpose of Koha::I18N is *not* to translate warning messages (warnings should not be in the language of the person actually using Koha), but it's the quickest way to test this (I think) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Make Koha::I18N easier to |Make Koha::I18N easier to |user |use -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |11904 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #5 from M. Tompsett <mtompset@hotmail.com> --- Comment on attachment 25664 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25664 Bug 11848: Move language detection function in C4::Languages Review of attachment 25664: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=11848&attachment=25664) ----------------------------------------------------------------- ::: C4/Context.pm @@ +1252,5 @@
+sub interface { + my ($class, $interface) = @_; + + if (defined $interface) {
You are using interface as both a get and set, correct? @@ +1253,5 @@
+sub interface { + my ($class, $interface) = @_; + + if (defined $interface) { + $interface ||= 'opac';
Why not // instead? Also, interface is defined. This line is pointless. @@ +1254,5 @@
+ my ($class, $interface) = @_; + + if (defined $interface) { + $interface ||= 'opac'; + $context->{interface} = $interface;
perhaps a lc or uc may be useful? maybe some validation of the value? @@ +1257,5 @@
+ $interface ||= 'opac'; + $context->{interface} = $interface; + } + + return $context->{interface};
What if you haven't set the interface and you get undef? It would seem the default assumption is 'opac'. Perhaps add a "// 'opac'"? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #6 from M. Tompsett <mtompset@hotmail.com> --- Comment on attachment 25664 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25664 Bug 11848: Move language detection function in C4::Languages Review of attachment 25664: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=11848&attachment=25664) ----------------------------------------------------------------- ::: t/Templates.t @@ +42,4 @@
}, );
+delete $ENV{HTTP_ACCEPT_LANGUAGE};
Good catch on this typo that has been there since 2013-07-12 14:57:11. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #7 from Julian Maurice <julian.maurice@biblibre.com> ---
You are using interface as both a get and set, correct? Correct!
Why not // instead? Also, interface is defined. This line is pointless. C4::Context->interface # getter only C4::Context->interface('') # getter and setter, set to opac because '' is a defined but false value
perhaps a lc or uc may be useful? maybe some validation of the value? What if you haven't set the interface and you get undef? It would seem the default assumption is 'opac'. Perhaps add a "// 'opac'"? Sure. I will provide a patch for these issues. But not immediately, maybe next week.
Thanks for the review! :) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #8 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 26426 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=26426&action=edit Bug 11848: Fix C4::Context::interface, add POD and UT -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #9 from Julian Maurice <julian.maurice@biblibre.com> --- Finally, earlier than expected ;) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #25664|0 |1 is obsolete| | --- Comment #10 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- Created attachment 26494 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=26494&action=edit [SIGNED-OFF] Bug 11848: Move language detection function in C4::Languages and store interface (intranet, opac) in context to not have to pass it as parameter. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> No koha-qa errors -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #25665|0 |1 is obsolete| | --- Comment #11 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- Created attachment 26495 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=26495&action=edit [SIGNED-OFF] Bug 11848: Make Koha::I18N easier to use Instead of writing use CGI; use Koha::I18N; my $cgi = new CGI; my $lh = Koha::I18N->get_handle_from_context($cgi, 'intranet'); print $lh->maketext('my translatable text'); you can now write use Koha::I18N; print gettext('my translatable text'); Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> No errors -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #26426|0 |1 is obsolete| | --- Comment #12 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- Created attachment 26496 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=26496&action=edit [SIGNED-OFF] Bug 11848: Fix C4::Context::interface, add POD and UT Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Follow test plan, work as described. No koha-qa errors. Tests pass Fixed small merge conflict on t/Context.t -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |bgkriegel@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 27747 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=27747&action=edit [PASSED QA] Bug 11848: Move language detection function in C4::Languages and store interface (intranet, opac) in context to not have to pass it as parameter. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> No koha-qa errors Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Comments on last patch. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #14 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 27748 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=27748&action=edit [PASSED QA] Bug 11848: Make Koha::I18N easier to use Instead of writing use CGI; use Koha::I18N; my $cgi = new CGI; my $lh = Koha::I18N->get_handle_from_context($cgi, 'intranet'); print $lh->maketext('my translatable text'); you can now write use Koha::I18N; print gettext('my translatable text'); Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> No errors Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 --- Comment #15 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 27749 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=27749&action=edit [PASSED QA] Bug 11848: Fix C4::Context::interface, add POD and UT 1/ Edit a Perl script, for example mainpage.pl 2/ add "use Koha::I18N;" to the top of file 3/ add a translatable message somewhere in the script (this have to be after the call to get_template_and_user). For example: warn gettext("This is a translated warning"); 4/ Create or update the PO files with misc/translator/translate create LANGCODE or misc/translator/translate update LANGCODE (LANGCODE should be enable in syspref 'languages') 5/ In misc/translator/po/LANGCODE-messages.po you should have your string, translate it (using a text editor or a PO file editor, make sure you don't have the "fuzzy" flag for this string). 6/ Go to mainpage.pl with active language being English with your browser and check your logs. You should see your string "This is a translated warning". 7/ Now change language to LANGCODE. Check your logs, you should have the string translated. Note: I chose to name the sub 'gettext' because it's the default keyword for xgettext for Perl. We can change it to whatever we want. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Follow test plan, work as described. No koha-qa errors. Tests pass Fixed small merge conflict on t/Context.t Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes all tests and QA script. Copied test plan from bug. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA CC| |katrin.fischer@bsz-bw.de -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #26496|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #26494|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #26495|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rel_3_16_candidate -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |11668 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master CC| |gmcharlt@gmail.com --- Comment #16 from Galen Charlton <gmcharlt@gmail.com> --- Pushed to master. Thanks, Julian! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11848 Bug 11848 depends on bug 8044, which changed state. Bug 8044 Summary: Localization for Perl scripts and modules http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8044 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Stable |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org