Bugzilla – Attachment 27749 Details for
Bug 11848
Make Koha::I18N easier to use
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11848: Fix C4::Context::interface, add POD and UT
PASSED-QA-Bug-11848-Fix-C4Contextinterface-add-POD.patch (text/plain), 3.68 KB, created by
Katrin Fischer
on 2014-04-28 21:24:42 UTC
(
hide
)
Description:
[PASSED QA] Bug 11848: Fix C4::Context::interface, add POD and UT
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-04-28 21:24:42 UTC
Size:
3.68 KB
patch
obsolete
>From 8eb489ddade1baef96212c535f9f3060a3fdf336 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 17 Mar 2014 23:25:37 +0100 >Subject: [PATCH] [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. >--- > C4/Context.pm | 20 +++++++++++++++++--- > t/Context.t | 16 +++++++++++++++- > 2 files changed, 32 insertions(+), 4 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 1bc70b2..4ca9755 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1261,15 +1261,29 @@ sub IsSuperLibrarian { > return ($userenv->{flags}//0) % 2; > } > >+=head2 interface >+ >+Sets the current interface for later retrieval in any Perl module >+ >+ C4::Context->interface('opac'); >+ C4::Context->interface('intranet'); >+ my $interface = C4::Context->interface; >+ >+=cut >+ > sub interface { > my ($class, $interface) = @_; > > if (defined $interface) { >- $interface ||= 'opac'; >- $context->{interface} = $interface; >+ $interface = lc $interface; >+ if ($interface eq 'opac' || $interface eq 'intranet') { >+ $context->{interface} = $interface; >+ } else { >+ warn "invalid interface : '$interface'"; >+ } > } > >- return $context->{interface}; >+ return $context->{interface} // 'opac'; > } > > 1; >diff --git a/t/Context.t b/t/Context.t >index 6775b8e..8febdb4 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > use DBI; >-use Test::More tests => 14; >+use Test::More tests => 24; > use Test::MockModule; > > BEGIN { >@@ -45,3 +45,17 @@ is(C4::Context::db_scheme2dbi('mysql'), 'mysql', 'ask for mysql, get mysql'); > is(C4::Context::db_scheme2dbi('Pg'), 'Pg', 'ask for Pg, get Pg'); > is(C4::Context::db_scheme2dbi('xxx'), 'mysql', 'ask for unsupported DBMS, get mysql'); > is(C4::Context::db_scheme2dbi(), 'mysql', 'ask for nothing, get mysql'); >+ >+# C4::Context::interface >+my $lastwarn; >+local $SIG{__WARN__} = sub { $lastwarn = $_[0] }; >+is(C4::Context->interface, 'opac'); >+is(C4::Context->interface('foobar'), 'opac'); >+like($lastwarn, qr/invalid interface : 'foobar'/); >+is(C4::Context->interface, 'opac'); >+is(C4::Context->interface('intranet'), 'intranet'); >+is(C4::Context->interface, 'intranet'); >+is(C4::Context->interface('foobar'), 'intranet'); >+is(C4::Context->interface, 'intranet'); >+is(C4::Context->interface('OPAC'), 'opac'); >+is(C4::Context->interface, 'opac'); >-- >1.8.3.2
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 11848
:
25664
|
25665
|
26426
|
26494
|
26495
|
26496
|
27747
|
27748
| 27749