From patchwork Wed Aug 15 11:01:27 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schwarzott X-Patchwork-Id: 12503 Received: from mail-out.m-online.net ([212.18.0.10]) by www.linuxtv.org with esmtp (Exim 4.63) (envelope-from ) id 1ILGd0-0003UW-5w for vdr@linuxtv.org; Wed, 15 Aug 2007 13:01:30 +0200 Received: from mail01.m-online.net (mail.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id B67DD223B9E for ; Wed, 15 Aug 2007 13:01:29 +0200 (CEST) Received: from gauss.x.fun (DSL01.83.171.183.164.ip-pool.NEFkom.net [83.171.183.164]) by mail.nefkom.net (Postfix) with ESMTP id 91C0990D32 for ; Wed, 15 Aug 2007 13:01:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by gauss.x.fun (Postfix) with ESMTP id 67AF7F72C8 for ; Wed, 15 Aug 2007 13:01:28 +0200 (CEST) From: Matthias Schwarzott To: vdr@linuxtv.org Date: Wed, 15 Aug 2007 13:01:27 +0200 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Message-Id: <200708151301.28007.zzam@gentoo.org> Subject: [vdr] improving i18n-to-gettext.pl X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2007 11:01:30 -0000 Status: O X-Status: X-Keywords: X-UID: 13737 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 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 () { 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