From 0979904dfca6da24d45d06f9c2e9a692d56eb150 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 15 Aug 2007 12:52:00 +0200 Subject: [PATCH] Improved i18n-to-gettext.pl --- CONTRIBUTORS | 1 + HISTORY | 3 ++- i18n-to-gettext.pl | 23 +++++++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 1abcec16..764f253b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2085,6 +2085,7 @@ Tomas Berglund Matthias Schwarzott for suggesting to add LC_ALL to the checks for UTF-8 at startup for fixing getting the code setting from the locale + for improving i18n-to-gettext.pl Martin Ostermann for fixing processing the PDCDescriptor in 'libsi' on big endian systems diff --git a/HISTORY b/HISTORY index cc85173b..eacebfc5 100644 --- a/HISTORY +++ b/HISTORY @@ -5346,8 +5346,9 @@ Video Disk Recorder Revision History - Added a debug error message to cReceiver::~cReceiver() in case it is still attached to a device (thanks to Reinhard Nissl). -2007-08-12: Version 1.5.8 +2007-08-15: Version 1.5.8 - Added missing install-i18n to the install target in the Makefile (reported by Joachim Wilke). - Fixed a faulty comment in Make.config.template (reported by Marco Schlüßler). +- Improved i18n-to-gettext.pl (thanks to Matthias Schwarzott). diff --git a/i18n-to-gettext.pl b/i18n-to-gettext.pl index 79b2aab7..130122d4 100755 --- a/i18n-to-gettext.pl +++ b/i18n-to-gettext.pl @@ -10,7 +10,7 @@ # See the main source file 'vdr.c' for copyright information and # how to reach the author. # -# $Id: i18n-to-gettext.pl 1.2 2007/08/12 10:02:01 kls Exp $ +# $Id: i18n-to-gettext.pl 1.3 2007/08/15 12:52:00 kls Exp $ # How to convert an actual plugin: # @@ -75,7 +75,7 @@ die "can't find plugin name!" unless ($PLUGIN); # 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.[ch] explicitly first chomp($f = $_); if (-f $f && `grep tI18nPhrase $f`) { $I18NFILE = $f; @@ -204,13 +204,28 @@ $POTFILE = "$PODIR/$PLUGIN.pot"; # Collect all translated texts: open(F, $I18NFILE) || die "$I18NFILE: $!\n"; +$InComment = 0; while () { 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 (/\/\*/) { + $InComment = 1; + s/\/\*.*$//; # remove start of comment + } + elsif (/\*\//) { + $InComment = 0; + s/^.*\*\///; # remove end of comment + } + elsif ($InComment) { + 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 @@ -324,7 +339,7 @@ while () { $_ .= " i18n"; } elsif (/^clean:/) { - $_ .= "\n\t\@-rm -f \$(PODIR)/*.mo \$(PODIR)/*.pot"; + $_ .= "\n\t\@-rm -f \$(PODIR)/*.mo \$(PODIR)/*.pot"; } print NEW "$_\n"; }