OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/update-desktop-files?expand=0&rev=7
This commit is contained in:
parent
bd7b309e9d
commit
a3ac914367
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:68921b3e1210bcbfe825dbe933b7d597cad694bee9677e984c1ae84e2ccd9f10
|
||||
size 54888
|
||||
oid sha256:63f903988564510f97659013b4ad13f5e49992b2ce33594fe6a19b765860d752
|
||||
size 3563965
|
||||
|
@ -314,9 +314,16 @@ if [ "$I18N" = "yes" ]; then
|
||||
#
|
||||
# Merge translations
|
||||
#
|
||||
cp $FILE ${FILE}.old
|
||||
for L in /usr/share/update-desktop-files/locale/translations_*; do
|
||||
perl /usr/share/update-desktop-files/translate.pl $L $FILE > ${FILE}_ && mv ${FILE}_ $FILE || exit 1
|
||||
done
|
||||
perl /usr/share/update-desktop-files/untranslate.pl $FILE > ${FILE}.new
|
||||
if ! cmp -s ${FILE}.old {FILE}.new; then
|
||||
echo "UNTRANSLATE DOES NOT WORK"
|
||||
diff -u ${FILE}.old {FILE}.new
|
||||
fi
|
||||
rm -f ${FILE}.old ${FILE}.new
|
||||
else
|
||||
#
|
||||
# this file will not get translated
|
||||
|
60
translate.pl
60
translate.pl
@ -1,22 +1,37 @@
|
||||
$L=$ARGV[0];
|
||||
$LANGUAGE=$ARGV[0];
|
||||
$FILE=$ARGV[1];
|
||||
|
||||
use File::Basename;
|
||||
$L =~ s,/*$,,;
|
||||
$lang = basename($L);
|
||||
$LANGUAGE =~ s,/*$,,;
|
||||
$lang = basename($LANGUAGE);
|
||||
$lang =~ s/translations_//;
|
||||
$file = basename($FILE);
|
||||
|
||||
my %origs;
|
||||
my %trans;
|
||||
|
||||
opendir(DOMS, "$L/en_US/LC_MESSAGES/") || die "opendir $L";
|
||||
my $group = '';
|
||||
my %added = ();
|
||||
|
||||
opendir(DOMS, "$LANGUAGE/en_US/LC_MESSAGES/") || die "opendir $LANGUAGE";
|
||||
@mos = grep { /\.mo$/ } readdir(DOMS);
|
||||
close DOMS;
|
||||
|
||||
sub flush_translation()
|
||||
{
|
||||
foreach $tag ('Name', 'Comment', 'GenericName')
|
||||
my $list = $added{$group};
|
||||
|
||||
foreach $tag ('Name', 'Comment', 'GenericName')
|
||||
{
|
||||
next if (!defined $trans{$tag});
|
||||
$list = "$tag,$lang;$list";
|
||||
}
|
||||
|
||||
if ($list) {
|
||||
print "X-SuSE-added=$list\n";
|
||||
}
|
||||
|
||||
foreach $tag ('Name', 'Comment', 'GenericName')
|
||||
{
|
||||
next if (!defined $trans{$tag});
|
||||
#print "#SUSE-Addition\n";
|
||||
@ -27,9 +42,37 @@ sub flush_translation()
|
||||
}
|
||||
|
||||
my $flagged = 0;
|
||||
my $group = '';
|
||||
|
||||
|
||||
open(FILE, "$FILE");
|
||||
while ( <FILE> ) {
|
||||
|
||||
# new group
|
||||
if ($_ =~ /^\[/ )
|
||||
{
|
||||
my $line = $_;
|
||||
chomp $line;
|
||||
$group = $line;
|
||||
}
|
||||
|
||||
if ($_ =~ /^X-SuSE-added=/) {
|
||||
if (defined $added{$group}) {
|
||||
print STDERR "X-SuSE-added twice in $group\n";
|
||||
exit(1);
|
||||
}
|
||||
chomp $_;
|
||||
$_ =~ s,^X-SuSE-added=,,;
|
||||
$added{$group} = $_;
|
||||
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
open(FILE, "$FILE");
|
||||
|
||||
$group = '';
|
||||
|
||||
while ( <FILE> )
|
||||
{
|
||||
$flagged = 1 if ($_ =~ /X-SuSE-translate=true/ && $group eq '[Desktop Entry]');
|
||||
@ -63,7 +106,7 @@ while ( <FILE> )
|
||||
foreach $domain (@mos)
|
||||
{
|
||||
$domain=basename($domain, ".mo");
|
||||
$ENV{"TEXTDOMAINDIR"} = $L;
|
||||
$ENV{"TEXTDOMAINDIR"} = $LANGUAGE;
|
||||
$ENV{"LC_ALL"} = "en_US.UTF-8";
|
||||
open(GETTEXT, "-|", "gettext", "-d", "$domain", "$text");
|
||||
$transe=<GETTEXT>;
|
||||
@ -109,6 +152,9 @@ while ( <FILE> )
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
next if ($_ =~ /^X-SuSE-added=/);
|
||||
|
||||
print $_ if ($_);
|
||||
}
|
||||
|
||||
|
84
untranslate.pl
Normal file
84
untranslate.pl
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
my $FILE=$ARGV[0];
|
||||
|
||||
use File::Basename;
|
||||
|
||||
my $group = '';
|
||||
my $overwrite = '';
|
||||
my %added = ();
|
||||
|
||||
open(FILE, "$FILE");
|
||||
while ( <FILE> ) {
|
||||
|
||||
# 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 ( <FILE> ) {
|
||||
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 ($_);
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed May 2 19:18:34 CEST 2007 - coolo@suse.de
|
||||
|
||||
- add support for untranslate (so we can grab upstream translations
|
||||
reliable)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Apr 29 00:47:21 CEST 2007 - ro@suse.de
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
Name: update-desktop-files
|
||||
Version: 10.3
|
||||
Release: 11
|
||||
Release: 14
|
||||
Summary: A Build Tool to Update Desktop Files
|
||||
License: GNU General Public License (GPL)
|
||||
Group: Development/Tools/Building
|
||||
@ -24,6 +24,7 @@ Source: suse_update_desktop_file.sh
|
||||
Source1: map-desktop-category.sh
|
||||
Source2: kappfinder.tar.bz2
|
||||
Source3: translate.pl
|
||||
Source4: untranslate.pl
|
||||
# pdb query --filter "needshw:sound" | sed -e "s, ,,g"
|
||||
Source5: packages-sound
|
||||
# pdb query --filter "needshw:3d" | sed -e "s, ,,g"
|
||||
@ -82,7 +83,7 @@ for lang in *; do
|
||||
done
|
||||
fi
|
||||
done
|
||||
install -m 0644 %SOURCE5 %SOURCE6 %SOURCE3 $RPM_BUILD_ROOT/usr/share/%name/
|
||||
install -m 0644 %SOURCE5 %SOURCE6 %SOURCE3 %SOURCE4 $RPM_BUILD_ROOT/usr/share/%name/
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/%name/templates
|
||||
tar xfj %SOURCE2 -C $RPM_BUILD_ROOT/usr/share/%name/templates
|
||||
tar xfj %SOURCE7 -C $RPM_BUILD_ROOT/usr/share/%name/
|
||||
@ -122,6 +123,9 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/usr/share/locale/*/LC_MESSAGES/*mo
|
||||
|
||||
%changelog
|
||||
* Wed May 02 2007 - coolo@suse.de
|
||||
- add support for untranslate (so we can grab upstream translations
|
||||
reliable)
|
||||
* Sun Apr 29 2007 - ro@suse.de
|
||||
- ignore return code of validation for now, it causes too much
|
||||
breakage
|
||||
|
Loading…
Reference in New Issue
Block a user