#!/usr/bin/env perl use strict; use warnings; use Pod::Usage; use Getopt::Long; use File::Temp qw/tempdir/; use Path::Class qw/file dir/; require Locale::Maketext::Simple; my $help; my $path; my $locale; GetOptions( 'p|path=s' => \$path, 'l|locale=s' => \$locale, 'h|help' => \$help, ); pod2usage(0) if $help; pod2usage(1) unless $path && $locale; my @files = @ARGV or pod2usage(1); my $tempdir = dir( tempdir( CLEANUP => 1 ) ); Locale::Maketext::Simple->import( Path => $path, ); loc_lang($locale); my @newfiles; for my $file (@files) { my $data = file($file)->slurp; $data =~ s/{{(.+?)}}/loc($1)/egsmx; $data =~ s/_\((['"])(.+?)\1\)/loc($1)/egsmx; my $newfile = $tempdir->file( file($file)->basename ); my $fh = $newfile->openw or die; print $fh $data; $fh->close; push @newfiles, $newfile->stringify; } exit system('jemplate', '-c', @newfiles); =head1 NAME jemplate-maketext.pl - Jemplate wrapper script for Maketext =head1 SYNOPSIS jemplate-maketext.pl --path [.po files dir] --locale [locale] templatefiles... > jemplate_ja.js options: -p --path PO and MO files path -l --locale locale of transration -h --help show this help =head1 AUTHOR Daisuke Murase =cut