line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Typist; |
2
|
1
|
|
|
1
|
|
1260
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
60
|
|
3
|
1
|
|
|
1
|
|
22
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
74
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
23
|
use base 'Class::Accessor::Fast'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1533
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
11671
|
use Typist::L10N; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
9
|
use vars qw( $typist $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
394
|
|
10
|
|
|
|
|
|
|
$VERSION = 0.02; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @FIELDS = qw( prefix publish_charset timezone_offset tmpl_path ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Typist->mk_accessors(@FIELDS); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
1
|
|
|
1
|
1
|
3
|
my ($class, %param) = @_; |
18
|
1
|
|
|
|
|
3
|
my $self = bless {}, $class; |
19
|
1
|
50
|
|
|
|
2
|
map { $self->$_($param{$_}) if $param{$_} } @FIELDS; |
|
4
|
|
|
|
|
10
|
|
20
|
1
|
50
|
|
|
|
5
|
$self->prefix('MT') unless $self->prefix; |
21
|
1
|
|
|
|
|
20
|
$typist = $self; |
22
|
1
|
|
|
|
|
5
|
$self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub instance { |
26
|
2
|
100
|
|
2
|
1
|
15
|
return $typist if $typist; |
27
|
1
|
|
|
|
|
3
|
my $class = shift; |
28
|
1
|
|
|
|
|
4
|
$typist = $class->new(@_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $has_encode = ($] > 5.007003) && (eval { require Encode; 1 }); |
32
|
|
|
|
|
|
|
my %encode_map = ( |
33
|
|
|
|
|
|
|
'shiftjis' => 'shift_jis', |
34
|
|
|
|
|
|
|
'iso-2022-jp' => 'jis', |
35
|
|
|
|
|
|
|
'euc-jp' => 'euc', |
36
|
|
|
|
|
|
|
'utf-8' => 'utf-8', |
37
|
|
|
|
|
|
|
'utf8' => 'utf-8', |
38
|
|
|
|
|
|
|
'iso-8859-1' => 'iso-8859-1', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $LH; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
0
|
|
sub set_language { $LH = Typist::L10N->get_handle($_[1]) } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub translate { |
46
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
47
|
0
|
|
|
|
|
|
my $phrase = $LH->maketext(@_); |
48
|
0
|
0
|
0
|
|
|
|
return $phrase if $LH->ascii_only || !$has_encode; |
49
|
0
|
|
|
|
|
|
my $from = lc $LH->encoding; |
50
|
0
|
|
0
|
|
|
|
$from = $encode_map{$from} || $from; |
51
|
0
|
|
0
|
|
|
|
my $to = lc(Typist->instance->publish_charset || $from); |
52
|
0
|
|
0
|
|
|
|
$to = $encode_map{$to} || $to; |
53
|
0
|
0
|
|
|
|
|
Encode::from_to($phrase, $from, $to) if $to ne $from; |
54
|
0
|
|
|
|
|
|
$phrase; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub current_language { $LH->language_tag } |
58
|
0
|
|
|
0
|
1
|
|
sub language_handle { $LH } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |