line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::I18N::Web::View; |
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
7
|
use base qw(Template::Declare); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1262
|
|
5
|
|
|
|
|
|
|
use Template::Declare::Tags; |
6
|
|
|
|
|
|
|
use utf8; |
7
|
|
|
|
|
|
|
use Encode; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# XXX: take this out. |
10
|
|
|
|
|
|
|
*_ = sub { return @_; }; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub page (&) { |
13
|
|
|
|
|
|
|
my ($ref) = shift; |
14
|
|
|
|
|
|
|
return sub { |
15
|
|
|
|
|
|
|
my ($class,$handler) = @_; |
16
|
|
|
|
|
|
|
html { |
17
|
|
|
|
|
|
|
head { |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
show 'head', $class, $handler; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
body { |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ref->( $class, $handler ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# move to template helpers |
34
|
|
|
|
|
|
|
sub js { |
35
|
|
|
|
|
|
|
outs_raw qq|\n| for @_; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub css { |
39
|
|
|
|
|
|
|
outs_raw qq|| for @_; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
template 'head' => sub { |
43
|
|
|
|
|
|
|
my ( $class, $handler ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
outs_raw qq|\n|; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
js qw( |
48
|
|
|
|
|
|
|
/static/jquery-1.4.2.js |
49
|
|
|
|
|
|
|
/static/jquery.jgrowl.js |
50
|
|
|
|
|
|
|
/static/app.js |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $mxhr = 0; |
54
|
|
|
|
|
|
|
if( $mxhr ) { |
55
|
|
|
|
|
|
|
js qw( |
56
|
|
|
|
|
|
|
/static/DUI.js |
57
|
|
|
|
|
|
|
/static/Stream.js); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
|
|
|
|
|
|
js qw(/static/jquery.ev.js); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
css qw( |
64
|
|
|
|
|
|
|
/static/jquery.jgrowl.css |
65
|
|
|
|
|
|
|
/static/app.css |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
outs_raw qq| |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
template 'edit_po' => sub { |
83
|
|
|
|
|
|
|
my ( $self, $handler, $translation ) = @_; |
84
|
|
|
|
|
|
|
my $po_opts = $handler->application->options; |
85
|
|
|
|
|
|
|
my $podir = $po_opts->{podir}; |
86
|
|
|
|
|
|
|
unless( $translation ) { |
87
|
|
|
|
|
|
|
$translation = File::Spec->catfile( $podir , $handler->request->param( 'lang' ) . ".po" ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $logger = App::I18N->logger(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
unless( -f $translation ) { |
93
|
|
|
|
|
|
|
$logger->info( "$translation doesnt exist." ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $LME = App::I18N->lm_extract(); |
97
|
|
|
|
|
|
|
$LME->read_po( $translation ) if -f $translation; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $lex = $LME->lexicon; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
h3 { "Po Web Server: " . $translation }; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# load all po msgid and msgstr |
104
|
|
|
|
|
|
|
form { { method is 'post' } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
div { |
107
|
|
|
|
|
|
|
outs "Editing po file: " . $translation; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
input { { type is 'hidden', name is 'pofile' , value is $translation } }; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
div { { class is 'msgitem' } |
113
|
|
|
|
|
|
|
div { { class is 'msgid column-header' } _("MsgID") } |
114
|
|
|
|
|
|
|
div { { class is 'msgstr column-header' } _("MsgStr") } |
115
|
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# XXX: a better way to read po file ? not to parse every time. |
118
|
|
|
|
|
|
|
while( my ($msgid,$msgstr) = each %$lex ) { |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
div { { class is 'msgitem' } |
121
|
|
|
|
|
|
|
div { { class is 'msgid' } |
122
|
|
|
|
|
|
|
textarea { { name is 'msgid[]' }; |
123
|
|
|
|
|
|
|
outs decode_utf8 $msgid; |
124
|
|
|
|
|
|
|
}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
div { { class is 'msgstr' } |
128
|
|
|
|
|
|
|
textarea { { name is 'msgstr[]' }; |
129
|
|
|
|
|
|
|
outs decode_utf8 $msgstr; |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
div { { class is 'clear' } }; |
139
|
|
|
|
|
|
|
div { { style is 'width: 80%; text-align:right;' }; |
140
|
|
|
|
|
|
|
input { { |
141
|
|
|
|
|
|
|
type is 'submit' , |
142
|
|
|
|
|
|
|
value is _("Write All") , |
143
|
|
|
|
|
|
|
onclick is qq|return writeAll(this);| |
144
|
|
|
|
|
|
|
} }; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
}; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
}; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
template '/entry_edit' => sub { |
154
|
|
|
|
|
|
|
div { { id is 'current-message' } |
155
|
|
|
|
|
|
|
div { { class is 'navbar' } |
156
|
|
|
|
|
|
|
input { { type is 'button' , class is 'prev-message' , value is 'Previous' } }; |
157
|
|
|
|
|
|
|
input { { type is 'button' , class is 'skip-message' , value is 'Next' } }; |
158
|
|
|
|
|
|
|
input { { type is 'button' , class is 'next-message' , value is 'Save and Next' } }; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
div { { id is 'message-content' } |
162
|
|
|
|
|
|
|
div { { id is 'current-lang' } } |
163
|
|
|
|
|
|
|
div { { id is 'current-msgid' } } |
164
|
|
|
|
|
|
|
textarea { { id is 'current-msgstr' , rows is 6 , cols is 60 , tabindex is 1 } } |
165
|
|
|
|
|
|
|
}; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
div { { class is 'navbar' } |
168
|
|
|
|
|
|
|
input { { type is 'button' , class is 'prev-message' , value is 'Previous' , tabindex is 4 } }; |
169
|
|
|
|
|
|
|
input { { type is 'button' , class is 'skip-message' , value is 'Next' , tabindex is 3 } }; |
170
|
|
|
|
|
|
|
input { { type is 'button' , class is 'next-message' , value is 'Save and Next' , tabindex is 2 } }; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
}; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
template '/' => page { |
176
|
|
|
|
|
|
|
my ( $class, $handler ) = @_; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $po_opts = $handler->application->options; |
179
|
|
|
|
|
|
|
my $podir = $po_opts->{podir}; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
h1 { "I18N" } |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
script { attr { type is 'text/javascript' } |
184
|
|
|
|
|
|
|
outs_raw <
|
185
|
|
|
|
|
|
|
END |
186
|
|
|
|
|
|
|
}; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
div { { id is 'langlist' } }; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
div { { id is 'panel' } |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# my $translation = |
195
|
|
|
|
|
|
|
# ( $po_opts->{pofile} ) |
196
|
|
|
|
|
|
|
# ? $po_opts->{pofile} |
197
|
|
|
|
|
|
|
# : $po_opts->{language} |
198
|
|
|
|
|
|
|
# ? File::Spec->catfile( $podir, $po_opts->{language} . ".po") |
199
|
|
|
|
|
|
|
# : undef; |
200
|
|
|
|
|
|
|
# |
201
|
|
|
|
|
|
|
# if( $translation ) { |
202
|
|
|
|
|
|
|
# show 'edit_po', $handler, $translation; |
203
|
|
|
|
|
|
|
# } |
204
|
|
|
|
|
|
|
# else { |
205
|
|
|
|
|
|
|
# # list language |
206
|
|
|
|
|
|
|
# use File::Find::Rule; |
207
|
|
|
|
|
|
|
# my @files = File::Find::Rule->file()->name( "*.po" )->in( $podir ); |
208
|
|
|
|
|
|
|
# foreach my $file (@files) { |
209
|
|
|
|
|
|
|
# my ($langname) = ( $file =~ m{([a-zA-Z-_]+)\.po$}i ); |
210
|
|
|
|
|
|
|
# input { attr { type is 'button', value is $file , onclick is qq| |
211
|
|
|
|
|
|
|
# return (function(e){ |
212
|
|
|
|
|
|
|
# jQuery.ajax({ |
213
|
|
|
|
|
|
|
# url: '/edit_po', |
214
|
|
|
|
|
|
|
# data: { lang: "$langname" }, |
215
|
|
|
|
|
|
|
# dataType: 'html', |
216
|
|
|
|
|
|
|
# type: 'get', |
217
|
|
|
|
|
|
|
# success: function(html) { |
218
|
|
|
|
|
|
|
# jQuery('#panel').html( html ); |
219
|
|
|
|
|
|
|
# } |
220
|
|
|
|
|
|
|
# }); |
221
|
|
|
|
|
|
|
# })(this);| } }; |
222
|
|
|
|
|
|
|
# } |
223
|
|
|
|
|
|
|
# } |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
}; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; |