X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-message-catalog;h=070f6b2f34e4dbb216b6fc872c1a376855c02755;hb=19bdd89959b314fd22b93dc520a79d86545af014;hp=dfb8ce3a462c71ee2b75026e273920fc5fb92e55;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/rt/sbin/rt-message-catalog b/rt/sbin/rt-message-catalog index dfb8ce3a4..070f6b2f3 100755 --- a/rt/sbin/rt-message-catalog +++ b/rt/sbin/rt-message-catalog @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -51,6 +51,9 @@ use warnings; use Locale::PO; use Getopt::Long; +use File::Temp 'tempdir'; + +use constant PO_DIR => 'share/po'; my %commands = ( stats => { }, @@ -81,7 +84,7 @@ exit; sub stats { my %opt = %{ shift() }; - my $dir = shift || 'lib/RT/I18N'; + my $dir = shift || PO_DIR; my $max = 0; my %res = (); @@ -125,7 +128,7 @@ sub stats { sub shrink { my %opt = %{ shift() }; - my $dir = shift || 'lib/RT/I18N'; + my $dir = shift || PO_DIR; my %keep = map { $_ => 1 } @{ $opt{'keep'} }; @@ -183,12 +186,11 @@ sub clean { sub rosetta { my %opt = %{ shift() }; - my $url = shift or die 'must provide rosseta download url or directory with new po files'; + my $url = shift or die 'must provide Rosetta download url or directory with new po files'; my $dir; - if ( $url =~ m/^[a-z]+:\/\// ) { - require File::Temp; - $dir = File::Temp::tempdir(); + if ( $url =~ m{^[a-z]+://} ) { + $dir = tempdir(); my ($fname) = $url =~ m{([^/]+)$}; print "Downloading $url\n"; @@ -207,7 +209,7 @@ sub rosetta { die "Is not URL or directory: '$url'"; } - my @files = <$dir/rt/*.po>, <$dir/*.po>; + my @files = ( <$dir/rt/*.po>, <$dir/*.po> ); unless ( @files ) { print STDERR "No files in $dir/rt/*.po and $dir/*.po\n"; exit; @@ -221,18 +223,17 @@ sub rosetta { for ( @files ) { my ($lang) = m/([\w_]+)\.po/; - my $fn_orig = "lib/RT/I18N/$lang.po"; + my $fn_orig = PO_DIR . "/$lang.po"; print "$_ -> $fn_orig\n"; # retain the "NOT FOUND IN SOURCE" entries - require File::Temp; my $tmp = File::Temp->new; system("sed -e 's/^#~ //' $_ > $tmp"); my $ext = Locale::Maketext::Extract->new; $ext->read_po($tmp); - my $po_orig = Locale::PO->load_file_ashash( -e $fn_orig? $fn_orig : 'lib/RT/I18N/rt.pot' ); + my $po_orig = Locale::PO->load_file_ashash( -e $fn_orig? $fn_orig : PO_DIR . '/rt.pot' ); # don't want empty vales to override ours. # don't want fuzzy flag as when uploading to rosetta again it's not accepted by rosetta. foreach my $msgid ($ext->msgids) { @@ -264,6 +265,6 @@ sub rosetta { sub extract { shift; - system($^X, 'sbin/extract-message-catalog', @_); + system($^X, 'devel/tools/extract-message-catalog', @_); }