801c5e77d0
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. Signed-off-by: Galen Charlton <gmc@esilibrary.com>
61 lines
2.2 KiB
Perl
Executable file
61 lines
2.2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
use DBI;
|
|
use Test::More tests => 24;
|
|
use Test::MockModule;
|
|
|
|
BEGIN {
|
|
use_ok('C4::Context');
|
|
}
|
|
|
|
my $context = new Test::MockModule('C4::Context');
|
|
my $userenv = {};
|
|
|
|
$context->mock('userenv', sub {
|
|
return $userenv;
|
|
});
|
|
|
|
local $SIG{__WARN__} = sub { die $_[0] };
|
|
|
|
eval { C4::Context::IsSuperLibrarian(); };
|
|
like ( $@, qr/not defined/, "IsSuperLibrarian logs an error if no userenv is defined" );
|
|
|
|
$userenv->{flags} = 42;
|
|
my $is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
|
|
is ( $@, q||, "IsSuperLibrarian does not log an error if userenv is defined" );
|
|
is ( $is_super_librarian, 0, "With flag=42, it is not a super librarian" );
|
|
|
|
$userenv->{flags} = 421;
|
|
$is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
|
|
is ( $@, q||, "IsSuperLibrarian does not log an error if userenv is defined" );
|
|
is ( $is_super_librarian, 1, "With flag=1, it is a super librarian" );
|
|
|
|
$userenv->{flags} = undef;
|
|
$is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
|
|
is ( $@, q||, "IsSuperLibrarian does not log an error if \$userenv->{flags} is undefined" );
|
|
is ( $is_super_librarian, 0, "With flag=undef, it is not a super librarian" );
|
|
|
|
$userenv->{flags} = 0;
|
|
$is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
|
|
is ( $@, q||, "IsSuperLibrarian does not log an error if \$userenv->{flags} is equal to 0" );
|
|
is ( $is_super_librarian, 0, "With flag=0, it is not a super librarian" );
|
|
|
|
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');
|