diff --git a/modules/trans.pl b/modules/trans.pl new file mode 100755 index 00000000..9713ba78 --- /dev/null +++ b/modules/trans.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +# quick and dirty interface to https://github.com/soimort/translate-shell + +use warnings; +use strict; + +if (not @ARGV) { + print "Usage: trans [options] [source]:[targets] \n"; + exit; +} + +my $args = quotemeta "@ARGV"; +$args =~ s/\\([ :-])/$1/g; +$args =~ s/^\s+|\s+$//g; + +my $opts = '-j'; +$opts .= ' -b' unless $args =~ /^-/; + +my $result = `trans $opts $args`; + +$result =~ s/\e\[\d+m//g; + +print "$result\n";