diff --git a/HISTORY b/HISTORY index 9071436..fe1cce8 100644 --- a/HISTORY +++ b/HISTORY @@ -12,10 +12,9 @@ VDR Plugin 'iptv' Revision History - Fixed shutdown logic. - Improved error checking in protocols. -2007-xx-xx: Version 0.0.3 +2007-10-28: Version 0.0.3 - Fixed shutdown crash. - Added some minor tweaks. - RTP payload now restricted to TS only. -- Added preliminary support for vdr-1.4.7 - without localization. +- Added preliminary support for vdr-1.4.7. diff --git a/Makefile b/Makefile index afa90f7..0c69a99 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.20 2007/10/21 13:31:21 ajhseppa Exp $ +# $Id: Makefile,v 1.21 2007/10/28 16:22:44 rahrenbe Exp $ # Debugging on/off #IPTV_DEBUG = 1 @@ -40,6 +40,9 @@ TMPDIR = /tmp APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h) +### Test whether VDR has locale support +VDRLOCALE = $(shell grep '^LOCALEDIR' $(VDRDIR)/Makefile) + ### The name of the distribution archive: ARCHIVE = $(PLUGIN)-$(VERSION) @@ -59,7 +62,7 @@ endif OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \ protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \ - sidscanner.o statistics.o common.o socket.o + sidscanner.o statistics.o common.o socket.o i18n.o ### The main target: @@ -75,7 +78,7 @@ all: libvdr-$(PLUGIN).so i18n MAKEDEP = $(CXX) -MM -MG DEPFILE = .dependencies $(DEPFILE): Makefile - @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(subst i18n.c,,$(OBJS:%.o=%.c)) > $@ -include $(DEPFILE) @@ -87,12 +90,21 @@ I18Npo = $(wildcard $(PODIR)/*.po) I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file)))) I18Ndirs = $(notdir $(foreach file, $(I18Npo), $(basename $(file)))) I18Npot = $(PODIR)/$(PLUGIN).pot +ifeq ($(strip $(APIVERSION)),1.5.7) +I18Nvdrmo = $(PLUGIN).mo +else +I18Nvdrmo = vdr-$(PLUGIN).mo +endif + +### Do gettext based i18n stuff + +ifneq ($(strip $(VDRLOCALE)),) %.mo: %.po msgfmt -c -o $@ $< $(I18Npot): $(wildcard *.c) - xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $(wildcard *.c) + xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $(subst i18n.c,,$(wildcard *.c)) $(I18Npo): $(I18Npot) msgmerge -U --no-wrap --no-location --backup=none -q $@ $< @@ -101,9 +113,25 @@ i18n: $(I18Npot) $(I18Nmo) @mkdir -p $(LOCALEDIR) for i in $(I18Ndirs); do\ mkdir -p $(LOCALEDIR)/$$i/LC_MESSAGES;\ - cp $(PODIR)/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/vdr-$(PLUGIN).mo;\ + cp $(PODIR)/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/$(I18Nvdrmo);\ done +i18n.c: i18n-template.c + @cp i18n-template.c i18n.c + +### Do i18n.c based i18n stuff + +else + +i18n: + @### nothing to do + +#i18n compatibility generator: +i18n.c: i18n-template.c po2i18n.pl $(I18Npo) + ./po2i18n.pl < i18n-template.c > i18n.c + +endif + ### Targets: libvdr-$(PLUGIN).so: $(OBJS) @@ -122,4 +150,4 @@ dist: clean @echo Distribution package created as $(PACKAGE).tgz clean: - @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot + @-rm -f $(OBJS) $(DEPFILE) i18n.c *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot diff --git a/README b/README index f0e9d2d..9a4afae 100644 --- a/README +++ b/README @@ -161,3 +161,5 @@ Notes: Acknowledgements: - The IPTV section filtering code is derived from Linux kernel. + +- Udo Richter's po2i18n package is used to support VDR's old i18n system. diff --git a/common.h b/common.h index 8ff1601..7e7fefe 100644 --- a/common.h +++ b/common.h @@ -3,13 +3,14 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: common.h,v 1.17 2007/10/26 23:18:49 rahrenbe Exp $ + * $Id: common.h,v 1.18 2007/10/28 16:22:44 rahrenbe Exp $ */ #ifndef __IPTV_COMMON_H #define __IPTV_COMMON_H #include +#include #include #ifdef DEBUG diff --git a/config.h b/config.h index 04f2ea0..1a7e66a 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: config.h,v 1.16 2007/10/20 17:26:46 rahrenbe Exp $ + * $Id: config.h,v 1.17 2007/10/28 16:22:44 rahrenbe Exp $ */ #ifndef __IPTV_CONFIG_H @@ -11,7 +11,6 @@ #include #include "common.h" -#include "config.h" class cIptvConfig { diff --git a/i18n-template.c b/i18n-template.c new file mode 100644 index 0000000..49309ed --- /dev/null +++ b/i18n-template.c @@ -0,0 +1,18 @@ +/* + * i18n.c: IPTV plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id: i18n-template.c,v 1.1 2007/10/28 16:22:44 rahrenbe Exp $ + */ + +#include "common.h" +#include "i18n.h" + +#if defined(APIVERSNUM) && APIVERSNUM < 10507 +const tI18nPhrase IptvPhrases[] = { +// START I18N +// END I18N + { NULL } + }; +#endif diff --git a/i18n.h b/i18n.h new file mode 100644 index 0000000..bc18f0a --- /dev/null +++ b/i18n.h @@ -0,0 +1,18 @@ +/* + * i18n.h: IPTV plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id: i18n.h,v 1.1 2007/10/28 16:22:44 rahrenbe Exp $ + */ + +#ifndef __IPTV_I18N_H +#define __IPTV_I18N_H + +#include + +#if defined(APIVERSNUM) && APIVERSNUM < 10507 +extern const tI18nPhrase IptvPhrases[]; +#endif + +#endif // __IPTV_I18N_H diff --git a/iptv.c b/iptv.c index 90e639c..1ebf5f5 100644 --- a/iptv.c +++ b/iptv.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: iptv.c,v 1.26 2007/10/26 23:13:24 rahrenbe Exp $ + * $Id: iptv.c,v 1.27 2007/10/28 16:22:44 rahrenbe Exp $ */ #include @@ -12,6 +12,7 @@ #include "config.h" #include "setup.h" #include "device.h" +#include "i18n.h" #ifndef PLUGINPARAMPATCHVERSNUM #error "You must apply the pluginparam patch for VDR!" @@ -21,8 +22,8 @@ #error "You must apply the closefilter patch for VDR!" #endif -static const char *VERSION = "0.0.3"; -static const char *DESCRIPTION = trNOOP("Experience the IPTV"); +static const char VERSION[] = "0.0.3"; +static const char DESCRIPTION[] = trNOOP("Experience the IPTV"); class cPluginIptv : public cPlugin { private: @@ -99,6 +100,9 @@ bool cPluginIptv::Initialize(void) { debug("cPluginIptv::Initialize()\n"); // Initialize any background activities the plugin shall perform. +#if defined(APIVERSNUM) && APIVERSNUM < 10507 + RegisterI18n(IptvPhrases); +#endif IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); return cIptvDevice::Initialize(deviceCount); } diff --git a/po2i18n.pl b/po2i18n.pl new file mode 100755 index 0000000..cef8092 --- /dev/null +++ b/po2i18n.pl @@ -0,0 +1,156 @@ +#!/usr/bin/perl +# +# po2i18n - Convert plugin po files in into i18n.c-format +# +# See the README file for copyright information and how to reach the author. +# + +use strict; +use warnings; + +my @LANGS = ( + "en_US", + "de_DE", + "sl_SI", + "it_IT", + "nl_NL", + "pt_PT", + "fr_FR", + "nn_NO", + "fi_FI", + "pl_PL", + "es_ES", + "el_GR", + "sv_SE", + "ro_RO", + "hu_HU", + "ca_ES", + "ru_RU", + "hr_HR", + "et_EE", + "da_DK", + "cs_CZ", + "tr_TR" + ); + +my %VERS = ( + "en_US" => 10200, + "de_DE" => 10200, + "sl_SI" => 10200, + "it_IT" => 10200, + "nl_NL" => 10200, + "pt_PT" => 10200, + "fr_FR" => 10200, + "nn_NO" => 10200, + "fi_FI" => 10200, + "pl_PL" => 10200, + "es_ES" => 10200, + "el_GR" => 10200, + "sv_SE" => 10200, + "ro_RO" => 10200, + "hu_HU" => 10200, + "ca_ES" => 10200, + "ru_RU" => 10302, + "hr_HR" => 10307, + "et_EE" => 10313, + "da_DK" => 10316, + "cs_CZ" => 10342, + "tr_TR" => 10502 + ); + + +my %strings; + +foreach my $lang (@LANGS) { $strings{$lang} = { }; } + + +sub LoadLanguage(*) { + my ($lang) = @_; + + if (!open FILE, "<", "po/$lang.po") { + return 0; + } + + my $msgid = ""; + my $msgstr = ""; + my $last = 0; # 0=init, 1=msgid was last, 2=msgstr was last + + while () { + chomp; + my $line = $_; + + if ($line =~ /^msgid "(.*)"$/) { + if ($last eq 2) { + $strings{$lang}->{$msgid} = $msgstr; + $strings{"en_US"}->{$msgid} = $msgid; + } + $msgid = $1; + $last = 1; + } elsif ($line =~ /^msgstr "(.*)"/) { + $msgstr = $1; + $last = 2; + } elsif ($line =~ /^"(.*)"/) { + if ($last eq 1) { + $msgid = $msgid . $1; + } elsif ($last eq 2) { + $msgstr = $msgstr . $1; + } + } + } + if ($last eq 2) { + $strings{$lang}->{$msgid} = $msgstr; + $strings{"en_US"}->{$msgid} = $msgid; + } + + close FILE; +} + + + +foreach my $lang (@LANGS) { + LoadLanguage($lang); +} + +my @msgids = sort keys %{$strings{"en_US"}}; + + +my $silent = 0; + +while (<>) { + my $line = $_; + + if ($line =~ /^\/\/ START I18N/) { + print "// START I18N - automatically generated by po2i18n.pl\n"; + for my $msgid (@msgids) { + next if $msgid eq ""; + + my $head = " { "; + my $endif = ""; + my $versnum = 10200; + + for my $lang (@LANGS) { + if ($VERS{$lang} ne $versnum) { + $versnum = $VERS{$lang}; + print $endif; + print "#if VDRVERSNUM >= $versnum\n"; + $endif = "#endif\n"; + } + my $msgstr = $strings{$lang}->{$msgid}; + $msgstr = "" if !defined $msgstr; + + print "$head\"$msgstr\",\n"; + $head = " "; + } + print $endif; + print " },\n"; + } + $silent = 1; + } + + if (!$silent) { print $line; } + + if ($line =~ /^\/\/ END I18N/) { + print "// END I18N - automatically generated by po2i18n.pl\n"; + $silent = 0; + } +}