From 5df6c2aefebe3d2abcc939a88e294876d59f03ca Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 17 Jun 2024 13:26:17 +0200 Subject: Adding upstream version 0.72. Signed-off-by: Daniel Baumann --- scripts/msgsearch | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100755 scripts/msgsearch (limited to 'scripts/msgsearch') diff --git a/scripts/msgsearch b/scripts/msgsearch new file mode 100755 index 0000000..e6d9de5 --- /dev/null +++ b/scripts/msgsearch @@ -0,0 +1,186 @@ +#! /usr/bin/env perl +eval 'exec perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + +# Copyright 2002, 2003, 2004 by Martin Quinson (mquinson#debian.org) +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of GPL v2.0 or later (see COPYING). + + +=head1 NAME + +msgsearch - Extract some messages of a po file based on several criteron + +=head1 SYNOPSIS + +msgsearch [-dhvV] -i EinputE -o EoutputE EfilterE + +=head1 DESCRIPTION + +msgsearch is an handy tool to extract some messages of a po file. Selection +depend on the file the message where extracted from, on the flags attached +to the message or even on their actual content. It can be seen as a +generalization of msggrep allowing you to use OR between different +categories. + +The used filters are very similar to the LDAP ones: + +=over + +=item * (EfieldE=argument) + +The EQ operator returns true (and thus select the message for +extraction) if and only if the value of the EfieldE is equal to the +string used as argument. The argument are Perl regular expression, so if +you want to get an equality (and not a substring search), you have to use ^value$. + +Existing fields are: + +=over + +=item - msgid + +The actual content of the message. + +=item - msgstr + +The actual content of the translation. + +=item - reference + +The location of the message in the file where it was extracted from. It is a +space separated list of positions, each ones being of the syntax +EfileE:Eline numberE. + +=item - comment + +Comment added manually (by the translators). + +=item - automatic + +Comment automatically added by the string extraction program. See the +I<--add-comments> option of the B program for more information. + +=item - flags + +space-separated list of all defined flags for this entry. + +Valid flags are: c-text, python-text, lisp-text, elisp-text, librep-text, +smalltalk-text, java-text, awk-text, object-pascal-text, ycp-text, +tcl-text, wrap, no-wrap and fuzzy. + +See the gettext documentation for their meaning. + +=back + +=item * (!EexpressionE) + +The NOT operator returns true if the sub-EexpressionE return false. + +=item * (&Eexpression1EEexpression2E...EexpressionNE) + +The AND operator returns true when all the sub-expression return true. It +return false if at least one of them return false. + +=item * (|Eexpression1EEexpression2E...EexpressionNE) + +The OR operator returns true when at least one of the sub-expression return +true. It return false if all of them return false. + +=head1 OPTIONS + +=over 4 + +=item -h, --help + +Show a short help message. + +=item -V, --version + +Displays the version of the script and exits. + +=item -i, --input + +Input file. By default, files are taken from the standard input. + +=item -o, --output + +Output file. By default, files are sent on the standard output. + +=item -v, --verbose + +Increase the verbosity of the program. + +=back + +=head1 SEE ALSO + +This tool is part of the po4a project, even if it can well prove useful in +other contexts. See L for more information about the motivations of +the po4a project, and the other tools developed in that framework. + +=head1 AUTHORS + + Martin Quinson (mquinson#debian.org) + +=head1 COPYRIGHT AND LICENSE + +Copyright 2004 by SPI, inc. + +This program is free software; you may redistribute it and/or modify it +under the terms of GPL v2.0 or later (see COPYING file). + +=cut + +use 5.16.0; +use strict; +use warnings; + +use Getopt::Long qw(GetOptions); + +use Locale::Po4a::Po; +use Locale::Po4a::Common; + +use Pod::Usage qw(pod2usage); + +textdomain('po4a'); + +sub show_version { + Locale::Po4a::Common::show_version("msgsearch"); + exit 0; +} + +my ($help,@verbose,$input,$output); +$help = 0; +@verbose = (); +$input = '-'; +$output = '-'; + +Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev'); +GetOptions( + 'input|i=s' => \$input, + 'output|o=s' => \$output, + 'help|h' => \$help, + 'verbose|v' => \@verbose, + 'version|V' => \&show_version +) || pod2usage(1); +$input eq '-' || -e $input || die sprintf(gettext("msgsearch: File '%s' does not exist")."\n",$input); +my $verbose = scalar @verbose; + +# Argument check +$help && pod2usage (0); +my $filter = shift(@ARGV) || pod2usage(1); + + +my $poin = Locale::Po4a::Po->new(); +# All following function croak on problem +print STDERR gettext("Read $input")."\n" if $verbose; +$poin->read($input); + +print STDERR gettext("Filter")."\n" if $verbose; +my $poout = $poin->filter($filter); + +print STDERR gettext("Write result to $output")."\n" if $verbose; +$poout->write($output); +0; -- cgit v1.2.3