App-I18N
view release on metacpan or search on metacpan
lib/App/I18N.pm view on Meta::CPAN
package App::I18N;
use strict;
use warnings;
use Carp;
use File::Copy;
use File::Find::Rule;
use File::Path qw/mkpath/;
use Locale::Maketext::Extract;
use Getopt::Long;
use Exporter 'import';
use JSON::XS;
use YAML::XS;
use File::Basename;
use Locale::Maketext::Extract;
use App::I18N::Logger;
use Cwd;
use Encode;
use File::Spec;
use MIME::Types ();
use constant USE_GETTEXT_STYLE => 1;
# our @EXPORT = qw(_);
our $VERSION = '0.034';
our $LOGGER;
our $LMExtract;
our $MIME = MIME::Types->new();
sub logger {
$LOGGER ||= App::I18N::Logger->new;
return $LOGGER;
}
Locale::Maketext::Lexicon::set_option( 'allow_empty' => 1 );
Locale::Maketext::Lexicon::set_option( 'use_fuzzy' => 1 );
Locale::Maketext::Lexicon::set_option( 'encoding' => "UTF-8" );
Locale::Maketext::Lexicon::set_option( 'style' => 'gettext' );
sub lm_extract {
return $LMExtract ||= Locale::Maketext::Extract->new(
plugins => {
'Locale::Maketext::Extract::Plugin::PPI' => [ 'pm','pl' ],
'tt2' => [ ],
# 'perl' => ['pl','pm','js','json'],
'perl' => [ '*' ], # _( ) , gettext( ) , loc( ) ...
'mason' => [ ] ,
'generic' => [ '*' ],
},
verbose => 1, warnings => 1 );
}
sub guess_appname {
return lc(basename(getcwd()));
}
sub pot_name {
my $self = shift;
return guess_appname();
}
sub _check_mime_type {
my $self = shift;
my $local_path = shift;
my $mimeobj = $MIME->mimeTypeOf($local_path);
my $mime_type = ($mimeobj ? $mimeobj->type : "unknown");
return if ( $mime_type =~ /^image/ );
return if ( $mime_type =~ /compressed/ ); # ignore compressed archive files
# return if ( $mime_type =~ /^application/ );
return 1;
( run in 0.578 second using v1.01-cache-2.11-cpan-6aa56a78535 )