File Coverage

blib/lib/MySQL/Admin/Translate.pm
Criterion Covered Total %
statement 25 28 89.2
branch 6 10 60.0
condition 7 12 58.3
subroutine 8 9 88.8
pod 4 4 100.0
total 50 63 79.3


line stmt bran cond sub pod time code
1             package MySQL::Admin::Translate;
2 2     2   13396 use strict;
  2         2  
  2         45  
3 2     2   7 use warnings;
  2         2  
  2         37  
4 2     2   477 use utf8;
  2         10  
  2         6  
5             require Exporter;
6 2     2   55 use vars qw($ACCEPT_LANGUAGE $lang $DefaultClass @EXPORT @ISA $defaultconfig);
  2         3  
  2         137  
7             @MySQL::Admin::Translate::EXPORT = qw(loadTranslate saveTranslate $lang);
8 2     2   317 use MySQL::Admin::Config;
  2         3  
  2         640  
9             @ISA = qw(Exporter MySQL::Admin::Config);
10             $MySQL::Admin::Translate::VERSION = '1.12';
11             $DefaultClass = 'MySQL::Admin::Translate' unless defined $MySQL::Admin::Translate::DefaultClass;
12             $defaultconfig = '/var/www/cgi-bin/config/translate.pl';
13              
14             =head1 NAME
15              
16             MySQL::Admin::Translate - Translations for MySQL::Admin.
17              
18             =head1 SYNOPSIS
19              
20             use MySQL::Admin::Translate;
21              
22             use vars qw($lang);
23              
24             loadTranslate("/srv/www/cgi-bin/config/translate.pl");
25              
26             *lang = \$MySQL::Admin::Translate::lang;
27              
28             print $lang->{de}{firstname}; #'Vorname'
29              
30             =head1 DESCRIPTION
31              
32             Translations for MySQL::Admin.
33              
34             =head2 EXPORT
35              
36             loadTranslate() saveTranslate() $lang
37              
38             =head1 Public
39              
40             =head2 new()
41              
42             =cut
43              
44             sub new {
45 3     3 1 5 my ($class, @initializer) = @_;
46 3         5 my $self = {};
47 3   33     16 bless $self, ref $class || $class || $DefaultClass;
48 3         9 return $self;
49             }
50              
51             =head2 loadTranslate()
52              
53             =cut
54              
55             sub loadTranslate {
56 3     3 1 14 my ($self, @p) = getSelf(@_);
57 3 100       7 my $do = (defined $p[0]) ? $p[0] : $defaultconfig;
58 3 100       60 if (-e $do) { do $do; }
  1         1482  
59             }
60              
61             =head2 saveTranslate()
62              
63             =cut
64              
65             sub saveTranslate {
66 0     0 1 0 my ($self, @p) = getSelf(@_);
67 0 0       0 my $l = defined $p[0] ? $p[0] : $defaultconfig;
68 0         0 $self->SUPER::saveConfig($l, $lang, 'lang');
69             }
70              
71             =head1 Private
72              
73             =head2 getSelf()
74              
75             =cut
76              
77             sub getSelf {
78 3 50 66 3 1 19 return @_ if defined($_[0]) && (!ref($_[0])) && ($_[0] eq 'MySQL::Admin::Translate');
      66        
79             return (
80 3 50 66     31 defined($_[0])
81             && (ref($_[0]) eq 'MySQL::Admin::Translate'
82             || UNIVERSAL::isa($_[0], 'MySQL::Admin::Translate'))
83             )
84             ? @_
85             : ($MySQL::Admin::Translate::DefaultClass->new, @_);
86             }
87              
88             =head2 see Also
89              
90             L L L L L L
91              
92             =head1 AUTHOR
93              
94             Dirk Lindner
95              
96             =head1 LICENSE
97              
98             Copyright (C) 2015 by Hr. Dirk Lindner
99              
100             This program is free software; you can redistribute it and/or
101             modify it under the terms of the GNU Lesser General Public License
102             as published by the Free Software Foundation;
103             This program is distributed in the hope that it will be useful,
104             but WITHOUT ANY WARRANTY; without even the implied warranty of
105             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106             GNU Lesser General Public License for more details.
107              
108             =cut
109              
110             1;