#!/usr/bin/perl -w my $FILE=$ARGV[0]; use File::Basename; my $group = ''; my $overwrite = ''; my %added = (); open(FILE, "$FILE"); while ( ) { # new group if ($_ =~ /^\[/ ) { my $line = $_; chomp $line; $group = $line; } if ($_ =~ /^X-SuSE-added=/) { my @translated = (); my $line = $_; chomp $line; $line =~ s,X-SuSE-added=,,; foreach my $tag (split(/;/, $line)) { my $tagname = $tag; $tagname =~ s/,.*//; $tag =~ s/^[^,]*,//; foreach my $lang (split(/,/, $tag)) { push(@translated, "$tagname\\[$lang\\]"); } } $added{$group} = \@translated; next; } } close(FILE); open(FILE, "$FILE"); my $addedtrans = $added{''}; while ( ) { next if ($_ =~ /X-SuSE-translate=true/ && $group eq '[Desktop Entry]'); next if ($_ =~ /X-SuSE-added=/ ); # new group if ($_ =~ /^\[/ ) { my $line = $_; chomp $line; $group = $line; print $_; $addedtrans = $added{$group}; next; } if ( $_ =~ /^$overwrite=/ ) { $overwrite = ''; next; } if ($_ =~ m/^#SUSE-Overwrite/) { $_ =~ s,^#SUSE-Overwrite ,,; my $line = $_; chomp $line; $line =~ s,=.*,,; $overwrite = "$line"; $overwrite = quotemeta $overwrite; print $_; next; } foreach $tag (@{$addedtrans}) { if ($_ =~ m/^$tag=/ ) { $_ = ''; last; } } print $_ if ($_); }