Current File : //usr/bin/intltool-prepare
#!/usr/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4  -*-

#  Intltool .desktop, .directory Prepare Tool
#
#  Copyright (C) 2001 Free Software Foundation.
#
#  Intltool is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License as
#  published by the Free Software Foundation; either version 2 of the
#  License, or (at your option) any later version.
#
#  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.
#
#  Author(s): Gediminas Paulauskas <[email protected]>
#	      Kenneth Christiansen <[email protected]>

## Release information
my $PROGRAM      = "intltool-prepare";
my $PACKAGE      = "intltool";
my $VERSION      = "0.50.2";

## Loaded modules
use strict;
use Getopt::Long;
use File::Find;

## Scalars used by the option stuff
my $HELP_ARG    = "0";
my $VERSION_ARG = "0";
my $VERBOSE     = "0";

my @languages;
my @desktop_files;
my $new;
my $file;

my $desktop_extension = "(desktop|soundlist|keys|directory)";

my $keywords = "Name|Comment|GenericName|SwallowTitle|description";

## Always print as the first thing
$| = 1;

## Handle options
GetOptions (
            "help|h"            => \$HELP_ARG,
            "version|v"         => \$VERSION_ARG,
            "verbose|x"         => \$VERBOSE
            ) or &invalid_option;


## Use the supplied arguments
## Check for options.
## This section will check for the different options.

sub split_on_argument {

    if ($VERSION_ARG) {
        &version;

    } elsif ($HELP_ARG) {
        &help;

    } else {
        &main;
    }
}

&split_on_argument;

sub main
{
    print "Working, please wait...\n" if (! $VERBOSE);
    &find_desktop_files;
    &append_keywords;
    &add_to_potfiles;
    &perform_rescue;
    &add_to_cvsignore;
    &fix_makefiles;
    &generate_empty;
}

sub version {
    print <<_EOF_;
${PROGRAM} ${PACKAGE} $VERSION
Written by Gediminas Paulauskas <menesis\@delfi.lt>, 2000.

Copyright (C) 2000 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
_EOF_
    exit;
}

sub help
{
    print <<_EOF_;
Usage: ${PROGRAM} [OPTION] KEYWORD...
Automates preparation steps before software make use of intltool.
KEYWORD is a list of additional key other than "Name", "Comment"
and "description".

  -h, --help                 shows this help page
  -v, --version              shows the version
  -x, --verbose              show lots of feedback

Report bugs to http://bugs.launchpad.net/intltool
_EOF_
    exit;
}

sub invalid_option
{
    ## Handle invalid arguments
    ## my $opt = $ARGV[0];
    ## print "$PROGRAM: invalid option -- $opt\n";
    print STDERR "Try `$PROGRAM --help' for more information.\n";
    exit 1;
}

sub append_keywords
{
    my $arg;
    foreach $arg (@ARGV) {
        $keywords .= "|$arg";
    }
}

sub add_to_potfiles
{
    open FILE, ">>po/POTFILES.in";
    my $intro = 0;
    foreach my $desktop (@desktop_files) {
        next if contains("po/POTFILES.in", "$desktop.in");
    # Print explanation comment only once
        unless ($intro) {
           print FILE "# files added by intltool-prepare\n";
           $intro = 1;
        }
        print FILE "$desktop.in\n";
    }
    close FILE;
}

sub perform_rescue
{
    foreach $file (@desktop_files) {
        &rescue_file($file);
    }
}

sub rescue_file
{
    my ($filename) = @_;
    my ($msgid, $line, $lang);

    print "Rescuing translations from $filename ...\n" if $VERBOSE;

    open ORIG, "<$filename";
    $line = 1;
ENTRY: while (<ORIG>) {
        chomp;
        $line++;
	    my $entry = $_;
        if (($entry =~ /^($keywords)=(.*)$/) ||
            ($entry =~ /^(\s*description)=(.*)$/)) {
            $msgid = $2;
            $msgid =~ s/\\/\\\\/g;
	    $msgid =~ s/\"/\\"/g;
        } elsif (($entry =~ /^($keywords)\[(.*?)\]=(.*)$/) ||
                 ($entry =~ /^(\s*\[)(.*?)\]description=(.*)$/)) {
            $lang = $2;

            my $msgstr = $3;
            $msgstr =~ s/\\/\\\\/g;
            $msgstr =~ s/"/\\"/g;
	    
            $line--;
            if ((-s "po/$lang.po") && 
                (contains("po/$lang.po", "msgid \"$msgid\""))) {
                next ENTRY;
            }
            
            open POFILE, ">>po/$lang.po";

            print POFILE "\n#: $filename.in:$line\n";
            print POFILE "msgid \"$msgid\"\n";
            print POFILE "msgstr \"$msgstr\"\n";

            close POFILE;
        }
    }
}

sub generate_empty
{
    my $all = ' ';
    foreach my $full (@desktop_files) {
        $new = "$full.in";
        $all .= "$new ";
	    print "Generating empty $new ...\n" if $VERBOSE;
        open FULL, "<$full";
        open NEW, ">$new";

        while (<FULL>) {
            unless (
		            (/^($keywords)\[.*?\]=.*$/) ||
        	        (/^\s*\[(.*?)\]description=.*$/)
		           ) {
                if (/^($keywords)=.*$/) {
                    print NEW "_$_";
                } elsif (/^(\s*)(description=.*)$/) {
                    print NEW "$1_$2\n";
                } else {
                    print NEW;
                }
	        }
        }

        close NEW;
    }
    unless ($all eq ' ') {
        print "*** Please add these files to CVS by following command: ***\n"
            . "cvs add$all\n";
    }
}

sub add_to_cvsignore
{
    my $all = ' ';
    my $ign;
    foreach $file (@desktop_files) {
        $file =~ /^(.*\/)?(.+?\.$desktop_extension$)$/;
        if ($1) {
            $ign = "$1.cvsignore";
        } else {
            $ign = ".cvsignore";
        }
        my $basename = $2;

        next if contains($ign, $basename);
	    
        print "Appending $basename to $ign\n" if $VERBOSE;
        open FILE, ">>$ign";
        print FILE "$basename\n";
        $all .= "$file ";
    }
    close FILE;
    unless ($all eq ' ') {
        print "*** Please remove files from CVS by following command: ***\n"
            . "cvs remove -f$all\n";
    }
}

sub fix_makefiles
{
    my $file;
    foreach $file (@desktop_files) {
        my ($makefile, $line);

        $file =~ /^(.*\/)?(.+?\.$desktop_extension$)$/;
        if ($1) {
            $makefile = "$1Makefile.am";
        } else {
            $makefile = "Makefile.am";
        }
        my $basename = $2;
        print "Fixing $basename entry in $makefile\n" if $VERBOSE;

        open MAKE, $makefile;
        open NEWMAKE, ">$makefile.new";
        my $extra = 0;
        while ($line = <MAKE>) {
            $extra = 1 if $line =~ /^EXTRA_DIST/;
            if ($extra) {
                if (($line =~ /$basename/) &&
                    !($line =~ /$basename\.in/)) {
                    $line =~ s/$basename/$basename\.in/;
                }
                $extra = 0 unless $line =~ /\\\s*$/
            } else {
                if ($line =~ /^(\w+)_DATA\s*=\s*$basename\s*$/) {
                    my $name = $1;
                    $line =~ s/^$name\_DATA/$name\_in_files/;
                    $line =~ s/$basename/$basename\.in/;
                    $basename =~ /\.($desktop_extension)$/;
                    my $ext = $1;
                    $line .= "$name\_DATA = \$($name\_in_files:.$ext.in=.$ext)\n";
                    $ext =~ tr/a-z/A-Z/;
                    if (!contains($makefile, "\@INTLTOOL_$ext\_RULE\@")) {
                        $line .= "\@INTLTOOL_$ext\_RULE\@\n";
                    }
                }
            }
            print NEWMAKE $line;
        }
        close NEWMAKE;
        rename "$makefile.new", $makefile;
    }
}

sub contains
{
    my ($name, $str) = @_;
    open CONT, "<$name";
    while (<CONT>) {
         chomp;
         return 1 if $_ eq $str;
    }
    return 0;
}

sub find_desktop_files
{
    if ($VERBOSE) {
        print "Found these interesting files:\n";
    } else {
        print "Finding interesting files...";
    }
    find (\&wanted, '.');
    print "done\n" unless $VERBOSE;
}

sub wanted
{
    if (/\.$desktop_extension$/) {
        my $file = $File::Find::name;
        $file =~ s/\.\///;
        push @desktop_files, $file;
        print "$file\n" if $VERBOSE;
    }
}

# vim: ts=4 sw=4 expandtab
blog

blog

Mostbet apk.527

Mostbet apk ▶️ PLAY Содержимое Mostbet Apk: A Comprehensive Guide What is Mostbet Apk? Features of Mostbet Apk Mostbet is a popular online betting and gaming platform that has been gaining traction globally. With its user-friendly interface and wide range of games and betting options, it’s no wonder why many …

Read More »

Krikya Online Casino in Bangladesh Customer Support.632

Krikya Online Casino in Bangladesh – Customer Support ▶️ PLAY Содержимое Responsive and Timely Support Multi-Channel Support Options Knowledge Base and FAQs General Information Games and Services Secure and Confidential Support In the rapidly growing online gaming industry, Krikya Online Casino has established itself as a prominent player in Bangladesh. …

Read More »

Mostbet AZ – bukmeker ve kazino Mostbet Giri rsmi sayt.5879

Mostbet AZ – bukmeker ve kazino Mostbet – Giriş rəsmi sayt ▶️ OYNA Содержимое Mostbet AZ rəsmi saytı haqqında məlumatlar Mostbet AZ-da qazanmaq üçün nəzərə alınmalıdır maliyyə planları Mostbet AZ-da maliyyə planı təyin etmək üçün nə qədər məbləği təyin etməliyim? mostbet AZ – bukmeker və kazino şirkətinin Azerbaycan üçün hazırladığı …

Read More »

Mostbet AZ – bukmeker ve kazino Mostbet Giri rsmi sayt.4013

Mostbet AZ – bukmeker ve kazino Mostbet – Giriş rəsmi sayt ▶️ OYNA Содержимое Mostbet AZ rəsmi saytı haqqında məlumatlar Mostbet AZ-da qeydiyyatdan keçmək Mostbet AZ-da qazanmaq üçün nəzərə alınmalıdır maliyyə tədbirləri Mostbet AZ-da oyun oynayın və kazanın Mostbet AZ – bukmeker və kazino şirkətinin Azerbaycan riyazi qazanlar üçün rəsmi …

Read More »

Casibom – casibom casino resmi gncel giri.902

Casibom – casibom casino resmi güncel giriş ▶️ OYNAMAK Содержимое Casibom Kasino Hakkında Temel Bilgiler Casibom Kasino Oyunları ve Bonus Programı Casibom Giriş ve Kayıt Casibom, en popüler ve güvenilir kasıtlı oyun sitelerinden biridir. Casibom 158 giriş sayesinde kullanıcılar, güvenli ve profesyonel bir ortamda çeşitli oyunları deneyebilirler. Cadibom adı ile …

Read More »

PariMatch (ПаріМатч) ставки на спорт та онлайн казино.3457

PariMatch (ПаріМатч) ставки на спорт та онлайн казино ▶️ ГРАТИ Содержимое ПариMatch – лідер українського ринку онлайн-ставок Преимущества Париматча Що таке PariMatch? Що може зробити PariMatch? Як зареєструватися на PariMatch Шаг 2: Введіть дані для реєстрації Оставки на спорт та онлайн-казино на PariMatch Що таке PariMatch? Переваги PariMatch Допомога та …

Read More »

Pinco Online Kazino (Пинко) 2025 Qaydalar və Şərtlər üzrə Bələdçi.153

Pinco Online Kazino (РџРёРЅРєРѕ) 2025 – Qaydalar vЙ™ ЕћЙ™rtlЙ™r ГјzrЙ™ BЙ™lЙ™dГ§i ▶️ OYNA Содержимое Pinco Online Kazino (РџРёРЅРєРѕ) 2025 – Qaydalar vЙ™ ЕћЙ™rtlЙ™r ГњzrЙ™ BЙ™lЙ™dГ§i Qeydiyyat vЙ™ Promokodlar TЙ™hlГјkЙ™sizlik vЙ™ Qaydalar Qeydiyyat vЙ™ Daxil Olma QaydalarД± Г–dЙ™niЕџ vЙ™ Г‡Д±xarД±Еџ QaydalarД± TЙ™hlГјkЙ™sizlik vЙ™ MЙ™xfilik QaydalarД± Bonus vЙ™ Kampaniya QaydalarД± Pinco online …

Read More »

Vavada Зеркало Вход на официальный сайт.1552

Вавада казино | Vavada Зеркало Вход на официальный сайт ▶️ ИГРАТЬ Содержимое Vavada Casino – Mirror – Entrance to the official website Преимущества использования Vavada зеркала Официальный сайт Vavada Миррор Vavada – безопасный доступ Преимущества игры в Vavada Большой выбор игр Безопасность и конфиденциальность Как начать играть в Vavada Выбор …

Read More »

Kasyno internetowe – jak sprawdzić licencję operatora.534

Kasyno internetowe – jak sprawdzić licencję operatora? ▶️ GRAĆ Содержимое Sposoby sprawdzania licencji Znaczenie licencji dla gracza Wady nieposiadania licencji Ważne informacje o kasynach online W dzisiejszym świecie, gdzie internet jest nieodłącznym elementem naszego życia, kasyna online stały się coraz bardziej popularne. W Polsce, gdzie hazard jest regulowany, wiele osób …

Read More »

– Официальный сайт Pinco Casino.2384 (2)

Пинко Казино – Официальный сайт Pinco Casino ▶️ ИГРАТЬ Содержимое Преимущества игроков в Pinco Casino Возможности для игроков Большой выбор игр Ограничения и условия В современном мире азартных игр, где каждый день появляются новые онлайн-казино, сложно найти надежный и проверенный игроком ресурс. Однако, pinco Casino – это исключение из правил. …

Read More »