App-I18N
view release on metacpan or search on metacpan
lib/App/I18N/Web/View.pm view on Meta::CPAN
package App::I18N::Web::View;
use warnings;
use strict;
use base qw(Template::Declare);
use Template::Declare::Tags;
use utf8;
use Encode;
# XXX: take this out.
*_ = sub { return @_; };
sub page (&) {
my ($ref) = shift;
return sub {
my ($class,$handler) = @_;
html {
head {
show 'head', $class, $handler;
}
body {
$ref->( $class, $handler );
}
};
}
}
# move to template helpers
sub js {
outs_raw qq|<script type="text/javascript" src="$_"></script>\n| for @_;
}
sub css {
outs_raw qq|<link href="$_" media="screen" rel="stylesheet" type="text/css" />| for @_;
}
template 'head' => sub {
my ( $class, $handler ) = @_;
outs_raw qq|<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n|;
js qw(
/static/jquery-1.4.2.js
/static/jquery.jgrowl.js
/static/app.js
);
my $mxhr = 0;
if( $mxhr ) {
js qw(
/static/DUI.js
/static/Stream.js);
}
else {
js qw(/static/jquery.ev.js);
}
css qw(
/static/jquery.jgrowl.css
/static/app.css
);
outs_raw qq|
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
if( typeof google != "undefined" ) {
google.load("language", "1");
}
</script>
|;
};
template 'edit_po' => sub {
my ( $self, $handler, $translation ) = @_;
my $po_opts = $handler->application->options;
my $podir = $po_opts->{podir};
unless( $translation ) {
$translation = File::Spec->catfile( $podir , $handler->request->param( 'lang' ) . ".po" );
}
my $logger = App::I18N->logger();
unless( -f $translation ) {
$logger->info( "$translation doesnt exist." );
}
my $LME = App::I18N->lm_extract();
$LME->read_po( $translation ) if -f $translation;
my $lex = $LME->lexicon;
h3 { "Po Web Server: " . $translation };
# load all po msgid and msgstr
form { { method is 'post' }
( run in 2.036 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )