intltool-update.in
来自「memprof source code, linux」· IN 代码 · 共 635 行 · 第 1/2 页
IN
635 行
#!@INTLTOOL_PERL@ -w## The Intltool Message Updater## Copyright (C) 2000-2002 Free Software Foundation.## Intltool is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License # version 2 published by the Free Software Foundation.## Intltool is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.## As a special exception to the GNU General Public License, if you# distribute this file as part of a program that contains a# configuration script generated by Autoconf, you may include it under# the same distribution terms that you use for the rest of that program.## Authors: Kenneth Christiansen <kenneth@gnu.org># Maciej Stachowiak# Darin Adler <darin@bentspoon.com>## Release informationmy $PROGRAM = "intltool-update";my $VERSION = "0.22";my $PACKAGE = "intltool";## Loaded modulesuse strict;use Getopt::Long;use Cwd;use File::Copy;use File::Find;## Scalars used by the option stuffmy $HELP_ARG = 0;my $VERSION_ARG = 0;my $DIST_ARG = 0;my $POT_ARG = 0;my $HEADERS_ARG = 0;my $MAINTAIN_ARG = 0;my $REPORT_ARG = 0;my $VERBOSE = 0;my $GETTEXT_PACKAGE = "";my @languages;my %po_files_by_lang = ();# Regular expressions to categorize file types.# FIXME: Please check if the following is correctmy $xml_extension ="xml(\.in)*|". # .in is not required"ui|"."glade2?(\.in)*|". # .in is not required"scm(\.in)*|". # .in is not required"oaf(\.in)+|"."etspec|"."sheet(\.in)+|"."schemas(\.in)+|"."pong(\.in)+";my $ini_extension ="desktop(\.in)+|"."caves(\.in)+|". "directory(\.in)+|"."soundlist(\.in)+|"."keys(\.in)+|"."server(\.in)+";## Always print as the first thing$| = 1;## Handle optionsGetOptions ( "help" => \$HELP_ARG, "version" => \$VERSION_ARG, "dist|d" => \$DIST_ARG, "pot|p" => \$POT_ARG, "headers|s" => \$HEADERS_ARG, "maintain|m" => \$MAINTAIN_ARG, "report|r" => \$REPORT_ARG, "verbose|x" => \$VERBOSE, "gettext-package|g=s" => \$GETTEXT_PACKAGE, ) or &print_error_invalid_option;&print_help if $HELP_ARG;&print_version if $VERSION_ARG;my $arg_count = ($DIST_ARG > 0) + ($POT_ARG > 0) + ($HEADERS_ARG > 0) + ($MAINTAIN_ARG > 0) + ($REPORT_ARG > 0);&print_help if $arg_count > 1;# --version and --help don't require a module namemy $MODULE = $GETTEXT_PACKAGE || &find_package_name;if ($DIST_ARG) { if ($ARGV[0] =~ /^[a-z]/){ &update_po_file ($ARGV[0]); &print_status ($ARGV[0]); } else { &print_help; }} elsif ($POT_ARG) { &generate_headers; &generate_po_template;} elsif ($HEADERS_ARG) { &generate_headers;} elsif ($MAINTAIN_ARG) { &find_leftout_files;} elsif ($REPORT_ARG) { &print_report;} else { if ($ARGV[0] =~ /^[a-z]/) { &main ($ARGV[0]); } else { &print_help; }}exit;#########sub print_version{ ## Print version information print "${PROGRAM} (${PACKAGE}) $VERSION\n"; print "Written by Kenneth Christiansen, Maciej Stachowiak, and Darin Adler.\n\n"; print "Copyright (C) 2000-2002 Free Software Foundation, Inc.\n"; print "This is free software; see the source for copying conditions. There is NO\n"; print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; exit;}sub print_help{ ## Print usage information print "Usage: ${PROGRAM} [OPTIONS] ...LANGCODE\n"; print "Updates PO template files and merge them with the translations.\n\n"; print " -p, --pot generate the PO template only\n"; print " -s, --headers generate the header files in POTFILES.in\n"; print " -m, --maintain search for left out files from POTFILES.in\n"; print " -r, --report display a status report for the module.\n"; print " -x, --verbose display lots of feedback\n"; print " --help display this help and exit\n"; print " --version output version information and exit\n"; print "\nExamples of use:\n"; print "${PROGRAM} --pot just creates a new PO template from the source\n"; print "${PROGRAM} da created new PO template and updated the da.po file\n\n"; print "Report bugs to bugzilla.gnome.org, module 'intltool'.\n"; exit;}sub main{ my ($lang) = @_; ## Report error if the language file supplied ## to the command line is non-existent &print_error_not_existing("$lang.po") if ! -s "$lang.po"; print "Working, please wait..." unless $VERBOSE; &generate_headers; &generate_po_template; &update_po_file ($lang); &print_status ($lang);}sub determine_type ($) { my $type = $_; my $gettext_type; # FIXME: Use $xml_extentions, and maybe do all this even nicer my $xml_regex = "(?:xml(\.in)*|ui|oaf(?:\.in)+|server(?:\.in)+|sheet(?:\.in)+|". "pong(?:\.in)+|etspec|schemas(?:\.in)+)"; my $ini_regex = "(?:desktop(?:\.in)+|caves(?:\.in)+|directory(?:\.in)+|". "soundlist(?:\.in)+)"; if ($type =~ /\[type: gettext\/([^\]].*)]/) { $gettext_type=$1; } elsif ($type =~ /schemas(\.in)+$/) { $gettext_type="schemas"; } elsif ($type =~ /$xml_regex$/) { $gettext_type="xml"; } elsif ($type =~ /glade2?(\.in)*$/) { $gettext_type="glade"; } elsif ($type =~ /$ini_regex$/) { $gettext_type="ini"; } elsif ($type =~ /scm(\.in)*$/) { $gettext_type="scheme"; } elsif ($type =~ /keys(\.in)+$/) { $gettext_type="keys"; } else { $gettext_type=""; } return "gettext\/$gettext_type";}sub find_leftout_files{ my (@buf_i18n_plain, @buf_i18n_xml, @buf_i18n_xml_unmarked, @buf_i18n_ini, @buf_potfiles, @buf_potfiles_ignore, @buf_allfiles, @buf_allfiles_sorted, @buf_potfiles_sorted ); ## Search and find all translatable files find sub { push @buf_i18n_plain, "$File::Find::name" if /\.(c|y|cc|cpp|c\+\+|h|gob)$/ }, ".."; find sub { push @buf_i18n_xml, "$File::Find::name" if /\.($xml_extension)$/ }, ".."; find sub { push @buf_i18n_ini, "$File::Find::name" if /\.($ini_extension)$/ }, ".."; find sub { push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/ }, ".."; open POTFILES, "POTFILES.in" or die "$PROGRAM: there's no POTFILES.in!\n"; @buf_potfiles = grep /^[^#]/, <POTFILES>; print "Searching for missing translatable files...\n" if $VERBOSE; ## Check if we should ignore some found files, when ## comparing with POTFILES.in foreach my $ignore ("POTFILES.skip", "POTFILES.ignore") { if (-s $ignore) { open FILE, $ignore; while (<FILE>) { if (/^[^#]/){ push @buf_potfiles_ignore, $_; } } print "Found $ignore: Ignoring files...\n" if $VERBOSE; @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles); } } foreach my $file (@buf_i18n_plain) { my $in_comment = 0; my $in_macro = 0; open FILE, "<$file"; while (<FILE>) { # Handle continued multi-line comment. if ($in_comment) { next unless s-.*\*/--; $in_comment = 0; } # Handle continued macro. if ($in_macro) { $in_macro = 0 unless /\\$/; next; } # Handle start of macro (or any preprocessor directive). if (/^\s*\#/) { $in_macro = 1 if /^([^\\]|\\.)*\\$/; next; } # Handle comments and quoted text. while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy { my $match = $1; if ($match eq "/*") { if (!s-/\*.*?\*/--) { s-/\*.*--; $in_comment = 1; } } elsif ($match eq "//") { s-//.*--; } else # ' or " { if (!s-$match([^\\]|\\.)*?$match-QUOTEDTEXT-) { warn "mismatched quotes at line $. in $file\n";
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?