improving i18n-to-gettext.pl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there!

This patch should improve i18n-to-gettext.pl to work with all plugins

1.It also lists i18n.h as there seem to be some plugin-writer putting 
translations there.
2. It also strips // comments being in lines without "," at the end.
3. it strips /* ... */ comments being in just one line
4. it strips /* ... */ comments spreading over multiple line
5. it just ignores #if and #endif lines (like used to make plugins compile 
with older vdr-versions which had less languages supported).


General question: Why is the locale dir called de_DE and not just de - as that 
seems what most other programs on my system do?

Matthias
-- 
Matthias Schwarzott (zzam)
Index: vdr-1.5.7/i18n-to-gettext.pl
===================================================================
--- vdr-1.5.7.orig/i18n-to-gettext.pl
+++ vdr-1.5.7/i18n-to-gettext.pl
@@ -75,7 +75,7 @@ die "can't find plugin name!" unless ($P
 # Locate the file containing the texts:
 
 $I18NFILE = "";
-for ("i18n.c", `ls *.c`) { # try i18n.c explicitly first
+for ("i18n.c", "i18n.h", `ls *.c`) { # try i18n.c explicitly first
     chomp($f = $_);
     if (-f $f && `grep tI18nPhrase $f`) {
        $I18NFILE = $f;
@@ -204,13 +204,26 @@ $POTFILE = "$PODIR/$PLUGIN.pot";
 # Collect all translated texts:
 
 open(F, $I18NFILE) || die "$I18NFILE: $!\n";
+$in_comment=0;
 while (<F>) {
       chomp;
       s/\t/ /g; # get rid of tabs
       s/  *$//; # get rid of trailing blanks
       s/^ *\/\/.*//; # remove comment lines
-      s/, *\/\/.*/,/; # strip trailing comments
+      s/ *\/\/.*//; # strip trailing comments
+      s/\/\*.*\*\///g; # strip c comments
+      if (/\/\*/) {
+        $in_comment=1;
+	s/\/\*.*$//; # remove starting of comment
+      } elsif (/\*\//) {
+        $in_comment=0;
+	s/^.*\*\///; # remove end of comment
+      } elsif ($in_comment) {
+        next;
+      }
       next if (/^ *$/); # skip empty lines
+      next if (/#if/);
+      next if (/#endif/);
       next unless ($found or $found = /const *tI18nPhrase .*{/); # sync on phrases
       next if (/const *tI18nPhrase .*{/); # skip sync line
       last if (/{ *NULL *}/); # stop after last phrase
_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux