1.1 --- a/Makefile Mon Jan 28 17:22:15 2008 +0100
1.2 +++ b/Makefile Mon Jan 28 17:39:51 2008 +0100
1.3 @@ -82,24 +82,35 @@
1.4
1.5 PODIR = po
1.6 I18Npot = $(PODIR)/$(PLUGIN).pot
1.7 -I18Nmsgs = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo,$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))))
1.8 +I18Npots := $(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))
1.9 +ifeq ($(strip $(APIVERSION)),1.5.7)
1.10 + I18Nmo = $(PLUGIN).mo
1.11 +else
1.12 + I18Nmo = vdr-$(PLUGIN).mo
1.13 +endif
1.14 LOCALEDIR = $(VDRDIR)/locale
1.15 +I18Nmsgs := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(I18Npots)))
1.16 +
1.17 +HASLOCALE = $(shell grep -l 'I18N_DEFAULT_LOCALE' $(VDRDIR)/include/vdr/i18n.h)
1.18 +ifeq ($(strip $(HASLOCALE)),)
1.19 + OBJS += i18n.o
1.20 +endif
1.21
1.22 ### Targets:
1.23
1.24 TARGETS = libvdr-$(PLUGIN).so
1.25 -ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c)
1.26 -TARGETS += i18n
1.27 +ifneq ($(strip $(HASLOCALE)),)
1.28 + TARGETS += i18n
1.29 endif
1.30
1.31 all: $(TARGETS)
1.32 -.PHONY: i18n
1.33 +.PHONY: i18n clean dist
1.34
1.35 # Dependencies:
1.36
1.37 MAKEDEP = $(CXX) -MM -MG
1.38 DEPFILE = .dependencies
1.39 -DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c))
1.40 +DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c)))
1.41 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
1.42 @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
1.43
1.44 @@ -114,7 +125,7 @@
1.45 $(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
1.46 @cp $@ $(LIBDIR)/$@.$(APIVERSION)
1.47
1.48 -$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR))
1.49 +$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c )
1.50 xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<s.huelswitt@gmx.de>' -o $@ $^
1.51
1.52 %.po: $(I18Npot)
1.53 @@ -124,12 +135,15 @@
1.54 %.mo: %.po
1.55 msgfmt -c -o $@ $<
1.56
1.57 -$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
1.58 +$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo
1.59 @mkdir -p $(dir $@)
1.60 cp $< $@
1.61
1.62 i18n: $(I18Nmsgs)
1.63
1.64 +i18n.c: $(PODIR)/*.po i18n-template.c po2i18n.pl
1.65 + perl ./po2i18n.pl <i18n-template.c >i18n.c
1.66 +
1.67 version.c: FORCE
1.68 @echo >$@.new "/* this file will be overwritten without warning */"; \
1.69 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
1.70 @@ -147,7 +161,7 @@
1.71
1.72 clean:
1.73 @-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~
1.74 - @-rm -f version.c
1.75 + @-rm -f version.c i18n.c
1.76 @-rm -f $(PODIR)/*.mo
1.77
1.78 FORCE:
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/README.po2i18n Mon Jan 28 17:39:51 2008 +0100
2.3 @@ -0,0 +1,44 @@
2.4 +
2.5 + po2i18n - Converter for po files
2.6 +
2.7 +
2.8 +Written by: Udo Richter <udo_richter@gmx.de>
2.9 +Project's homepage: http://www.udo-richter.de/vdr/scripts.html#po2i18n
2.10 + http://www.udo-richter.de/vdr/scripts.en.html#po2i18n
2.11 +
2.12 +
2.13 +
2.14 +About
2.15 +--------------------------------------------------------------------------
2.16 +po2i18n is a perl script that generates an i18n.c file compatible to the i18n
2.17 +system of VDR 1.2.0 - VDR 1.5.6, based on the .po files of VDR 1.5.7. This
2.18 +allows plugins to transit to the translation system of VDR 1.5.7 while
2.19 +maintaining compatibility to earlier versions. The script can be used manually
2.20 +or automatically as part of the Makefile.
2.21 +
2.22 +
2.23 +Use
2.24 +--------------------------------------------------------------------------
2.25 +po2i18n.pl is a filter and can be used manually like this:
2.26 +
2.27 + ./po2i18n.pl < i18n-template.c > i18n.c
2.28 +
2.29 +The filter reads all relevant ./po/*.po files and writes the i18n strings
2.30 +into the template file. Strings will be added between the following two lines:
2.31 +
2.32 + // START I18N
2.33 + // END I18N
2.34 +
2.35 +See also the sample i18n.h and i18n-template.c file. Note that the phrases data
2.36 +structure is encapsulated in #if VDRVERSNUM < 10507, so the i18n strings won't
2.37 +be in the plugin file after 1.5.7. The call to RegisterI18n() of your plugin
2.38 +should also be encapsulated like this.
2.39 +
2.40 +po2i18n can also generate the i18n.c file on the fly while compiling. The
2.41 +changes to the Makefile are demonstrated by the included Makefile.diff sample.
2.42 +With these changes, the i18n.c file will be generated on VDR up to 1.5.6, and
2.43 +the whole gettext conversion is skipped. From 1.5.7 on, the i18n-template.c
2.44 +file will be simply copied as a dummy, and the new locale system will run.
2.45 +
2.46 +As a drawback, the automatic .dependencies for i18n.c won't work.
2.47 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/i18n-template.c Mon Jan 28 17:39:51 2008 +0100
3.3 @@ -0,0 +1,18 @@
3.4 +/*
3.5 + * Auto generated file, do not edit
3.6 + * Will be overwritten/deleted without warning
3.7 + *
3.8 + * Edit the .po files if you want to update translations!!
3.9 + */
3.10 +
3.11 +#include "i18n.h"
3.12 +
3.13 +#if VDRVERSNUM < 10507
3.14 +
3.15 +const tI18nPhrase Phrases[] = {
3.16 +// START I18N
3.17 +// END I18N
3.18 + { NULL }
3.19 + };
3.20 +
3.21 +#endif
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/i18n.h Mon Jan 28 17:39:51 2008 +0100
4.3 @@ -0,0 +1,36 @@
4.4 +/*
4.5 + * PremiereEpg plugin to VDR (C++)
4.6 + *
4.7 + * (C) 2005-2008 Stefan Huelswitt <s.huelswitt@gmx.de>
4.8 + *
4.9 + * This code is base on the commandline tool premiereepg2vdr
4.10 + * (C) 2004-2005 by Axel Katzur software@katzur.de
4.11 + * but has been rewritten from scratch
4.12 + *
4.13 + * This code is free software; you can redistribute it and/or
4.14 + * modify it under the terms of the GNU General Public License
4.15 + * as published by the Free Software Foundation; either version 2
4.16 + * of the License, or (at your option) any later version.
4.17 + *
4.18 + * This code is distributed in the hope that it will be useful,
4.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.21 + * GNU General Public License for more details.
4.22 + *
4.23 + * You should have received a copy of the GNU General Public License
4.24 + * along with this program; if not, write to the Free Software
4.25 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4.26 + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
4.27 + */
4.28 +
4.29 +#ifndef ___I18N_H
4.30 +#define ___I18N_H
4.31 +
4.32 +#include <vdr/i18n.h>
4.33 +
4.34 +#if APIVERSNUM < 10507
4.35 +extern const tI18nPhrase Phrases[];
4.36 +#define trNOOP(s) (s)
4.37 +#endif
4.38 +
4.39 +#endif //___I18N_H
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/po2i18n.pl Mon Jan 28 17:39:51 2008 +0100
5.3 @@ -0,0 +1,156 @@
5.4 +#!/usr/bin/perl
5.5 +#
5.6 +# po2i18n - Convert plugin po files in into i18n.c-format
5.7 +#
5.8 +# See the README file for copyright information and how to reach the author.
5.9 +#
5.10 +
5.11 +use strict;
5.12 +use warnings;
5.13 +
5.14 +my @LANGS = (
5.15 + "en_US",
5.16 + "de_DE",
5.17 + "sl_SI",
5.18 + "it_IT",
5.19 + "nl_NL",
5.20 + "pt_PT",
5.21 + "fr_FR",
5.22 + "nn_NO",
5.23 + "fi_FI",
5.24 + "pl_PL",
5.25 + "es_ES",
5.26 + "el_GR",
5.27 + "sv_SE",
5.28 + "ro_RO",
5.29 + "hu_HU",
5.30 + "ca_ES",
5.31 + "ru_RU",
5.32 + "hr_HR",
5.33 + "et_EE",
5.34 + "da_DK",
5.35 + "cs_CZ",
5.36 + "tr_TR"
5.37 + );
5.38 +
5.39 +my %VERS = (
5.40 + "en_US" => 10200,
5.41 + "de_DE" => 10200,
5.42 + "sl_SI" => 10200,
5.43 + "it_IT" => 10200,
5.44 + "nl_NL" => 10200,
5.45 + "pt_PT" => 10200,
5.46 + "fr_FR" => 10200,
5.47 + "nn_NO" => 10200,
5.48 + "fi_FI" => 10200,
5.49 + "pl_PL" => 10200,
5.50 + "es_ES" => 10200,
5.51 + "el_GR" => 10200,
5.52 + "sv_SE" => 10200,
5.53 + "ro_RO" => 10200,
5.54 + "hu_HU" => 10200,
5.55 + "ca_ES" => 10200,
5.56 + "ru_RU" => 10302,
5.57 + "hr_HR" => 10307,
5.58 + "et_EE" => 10313,
5.59 + "da_DK" => 10316,
5.60 + "cs_CZ" => 10342,
5.61 + "tr_TR" => 10502
5.62 + );
5.63 +
5.64 +
5.65 +my %strings;
5.66 +
5.67 +foreach my $lang (@LANGS) { $strings{$lang} = { }; }
5.68 +
5.69 +
5.70 +sub LoadLanguage(*) {
5.71 + my ($lang) = @_;
5.72 +
5.73 + if (!open FILE, "<", "po/$lang.po") {
5.74 + return 0;
5.75 + }
5.76 +
5.77 + my $msgid = "";
5.78 + my $msgstr = "";
5.79 + my $last = 0; # 0=init, 1=msgid was last, 2=msgstr was last
5.80 +
5.81 + while (<FILE>) {
5.82 + chomp;
5.83 + my $line = $_;
5.84 +
5.85 + if ($line =~ /^msgid "(.*)"$/) {
5.86 + if ($last eq 2) {
5.87 + $strings{$lang}->{$msgid} = $msgstr;
5.88 + $strings{"en_US"}->{$msgid} = $msgid;
5.89 + }
5.90 + $msgid = $1;
5.91 + $last = 1;
5.92 + } elsif ($line =~ /^msgstr "(.*)"/) {
5.93 + $msgstr = $1;
5.94 + $last = 2;
5.95 + } elsif ($line =~ /^"(.*)"/) {
5.96 + if ($last eq 1) {
5.97 + $msgid = $msgid . $1;
5.98 + } elsif ($last eq 2) {
5.99 + $msgstr = $msgstr . $1;
5.100 + }
5.101 + }
5.102 + }
5.103 + if ($last eq 2) {
5.104 + $strings{$lang}->{$msgid} = $msgstr;
5.105 + $strings{"en_US"}->{$msgid} = $msgid;
5.106 + }
5.107 +
5.108 + close FILE;
5.109 +}
5.110 +
5.111 +
5.112 +
5.113 +foreach my $lang (@LANGS) {
5.114 + LoadLanguage($lang);
5.115 +}
5.116 +
5.117 +my @msgids = sort keys %{$strings{"en_US"}};
5.118 +
5.119 +
5.120 +my $silent = 0;
5.121 +
5.122 +while (<>) {
5.123 + my $line = $_;
5.124 +
5.125 + if ($line =~ /^\/\/ START I18N/) {
5.126 + print "// START I18N - automatically generated by po2i18n.pl\n";
5.127 + for my $msgid (@msgids) {
5.128 + next if $msgid eq "";
5.129 +
5.130 + my $head = " { ";
5.131 + my $endif = "";
5.132 + my $versnum = 10200;
5.133 +
5.134 + for my $lang (@LANGS) {
5.135 + if ($VERS{$lang} ne $versnum) {
5.136 + $versnum = $VERS{$lang};
5.137 + print $endif;
5.138 + print "#if VDRVERSNUM >= $versnum\n";
5.139 + $endif = "#endif\n";
5.140 + }
5.141 + my $msgstr = $strings{$lang}->{$msgid};
5.142 + $msgstr = "" if !defined $msgstr;
5.143 +
5.144 + print "$head\"$msgstr\",\n";
5.145 + $head = " ";
5.146 + }
5.147 + print $endif;
5.148 + print " },\n";
5.149 + }
5.150 + $silent = 1;
5.151 + }
5.152 +
5.153 + if (!$silent) { print $line; }
5.154 +
5.155 + if ($line =~ /^\/\/ END I18N/) {
5.156 + print "// END I18N - automatically generated by po2i18n.pl\n";
5.157 + $silent = 0;
5.158 + }
5.159 +}
6.1 --- a/premiereepg.c Mon Jan 28 17:22:15 2008 +0100
6.2 +++ b/premiereepg.c Mon Jan 28 17:39:51 2008 +0100
6.3 @@ -1,7 +1,7 @@
6.4 /*
6.5 * PremiereEpg plugin to VDR (C++)
6.6 *
6.7 - * (C) 2005-2007 Stefan Huelswitt <s.huelswitt@gmx.de>
6.8 + * (C) 2005-2008 Stefan Huelswitt <s.huelswitt@gmx.de>
6.9 *
6.10 * This code is base on the commandline tool premiereepg2vdr
6.11 * (C) 2004-2005 by Axel Katzur software@katzur.de
6.12 @@ -32,14 +32,12 @@
6.13 #include <vdr/config.h>
6.14 #include <libsi/section.h>
6.15 #include <libsi/descriptor.h>
6.16 +#include "i18n.h"
6.17 #include "version.h"
6.18
6.19 #if APIVERSNUM < 10401
6.20 #error You need at least VDR API version 1.4.1 for this plugin
6.21 #endif
6.22 -#if APIVERSNUM < 10507
6.23 -#define trNOOP(s) (s)
6.24 -#endif
6.25
6.26 //#define DEBUG
6.27 //#define DEBUG2
6.28 @@ -89,254 +87,6 @@
6.29 FixEpg=0;
6.30 }
6.31
6.32 -// --- i18n --------------------------------------------------------------------
6.33 -
6.34 -#if APIVERSNUM < 10507
6.35 -const tI18nPhrase Phrases[] = {
6.36 - { "PremiereEPG",
6.37 - "PremiereEPG",
6.38 - "", // TODO
6.39 - "", // TODO
6.40 - "", // TODO
6.41 - "", // TODO
6.42 - "", // TODO
6.43 - "", // TODO
6.44 - "", // TODO
6.45 - "", // TODO
6.46 - "", // TODO
6.47 - "", // TODO
6.48 - "", // TODO
6.49 - "", // TODO
6.50 - "", // TODO
6.51 - "", // TODO
6.52 - },
6.53 - { "Parses extended Premiere EPG data",
6.54 - "Liest erweiterte Premiere EPG Daten ein",
6.55 - "", // TODO
6.56 - "", // TODO
6.57 - "", // TODO
6.58 - "", // TODO
6.59 - "", // TODO
6.60 - "", // TODO
6.61 - "", // TODO
6.62 - "", // TODO
6.63 - "", // TODO
6.64 - "", // TODO
6.65 - "", // TODO
6.66 - "", // TODO
6.67 - "", // TODO
6.68 - "", // TODO
6.69 - },
6.70 - { "off",
6.71 - "aus",
6.72 - "", // TODO
6.73 - "", // TODO
6.74 - "", // TODO
6.75 - "", // TODO
6.76 - "", // TODO
6.77 - "", // TODO
6.78 - "", // TODO
6.79 - "", // TODO
6.80 - "", // TODO
6.81 - "", // TODO
6.82 - "", // TODO
6.83 - "", // TODO
6.84 - "", // TODO
6.85 - "", // TODO
6.86 - },
6.87 - { "Tag option events",
6.88 - "Options Events markieren",
6.89 - "", // TODO
6.90 - "", // TODO
6.91 - "", // TODO
6.92 - "", // TODO
6.93 - "", // TODO
6.94 - "", // TODO
6.95 - "", // TODO
6.96 - "", // TODO
6.97 - "", // TODO
6.98 - "", // TODO
6.99 - "", // TODO
6.100 - "", // TODO
6.101 - "", // TODO
6.102 - "", // TODO
6.103 - },
6.104 - { "Show order information",
6.105 - "Bestellhinweise anzeigen",
6.106 - "", // TODO
6.107 - "", // TODO
6.108 - "", // TODO
6.109 - "", // TODO
6.110 - "", // TODO
6.111 - "", // TODO
6.112 - "", // TODO
6.113 - "", // TODO
6.114 - "", // TODO
6.115 - "", // TODO
6.116 - "", // TODO
6.117 - "", // TODO
6.118 - "", // TODO
6.119 - "", // TODO
6.120 - },
6.121 - { "Show rating information",
6.122 - "Altersfreigaben anzeigen",
6.123 - "", // TODO
6.124 - "", // TODO
6.125 - "", // TODO
6.126 - "", // TODO
6.127 - "", // TODO
6.128 - "", // TODO
6.129 - "", // TODO
6.130 - "", // TODO
6.131 - "", // TODO
6.132 - "", // TODO
6.133 - "", // TODO
6.134 - "", // TODO
6.135 - "", // TODO
6.136 - "", // TODO
6.137 - },
6.138 -
6.139 - { "Ordernumber",
6.140 - "Bestellnummer",
6.141 - "", // TODO
6.142 - "", // TODO
6.143 - "", // TODO
6.144 - "", // TODO
6.145 - "", // TODO
6.146 - "", // TODO
6.147 - "", // TODO
6.148 - "", // TODO
6.149 - "", // TODO
6.150 - "", // TODO
6.151 - "", // TODO
6.152 - "", // TODO
6.153 - "", // TODO
6.154 - "", // TODO
6.155 - },
6.156 - { "Price",
6.157 - "Preis",
6.158 - "", // TODO
6.159 - "", // TODO
6.160 - "", // TODO
6.161 - "", // TODO
6.162 - "", // TODO
6.163 - "", // TODO
6.164 - "", // TODO
6.165 - "", // TODO
6.166 - "", // TODO
6.167 - "", // TODO
6.168 - "", // TODO
6.169 - "", // TODO
6.170 - "", // TODO
6.171 - "", // TODO
6.172 - },
6.173 - { "Ordering",
6.174 - "Bestellen",
6.175 - "", // TODO
6.176 - "", // TODO
6.177 - "", // TODO
6.178 - "", // TODO
6.179 - "", // TODO
6.180 - "", // TODO
6.181 - "", // TODO
6.182 - "", // TODO
6.183 - "", // TODO
6.184 - "", // TODO
6.185 - "", // TODO
6.186 - "", // TODO
6.187 - "", // TODO
6.188 - "", // TODO
6.189 - },
6.190 - { "SMS",
6.191 - "SMS",
6.192 - "", // TODO
6.193 - "", // TODO
6.194 - "", // TODO
6.195 - "", // TODO
6.196 - "", // TODO
6.197 - "", // TODO
6.198 - "", // TODO
6.199 - "", // TODO
6.200 - "", // TODO
6.201 - "", // TODO
6.202 - "", // TODO
6.203 - "", // TODO
6.204 - "", // TODO
6.205 - "", // TODO
6.206 - },
6.207 - { "WWW",
6.208 - "WWW",
6.209 - "", // TODO
6.210 - "", // TODO
6.211 - "", // TODO
6.212 - "", // TODO
6.213 - "", // TODO
6.214 - "", // TODO
6.215 - "", // TODO
6.216 - "", // TODO
6.217 - "", // TODO
6.218 - "", // TODO
6.219 - "", // TODO
6.220 - "", // TODO
6.221 - "", // TODO
6.222 - "", // TODO
6.223 - },
6.224 - { "Rating",
6.225 - "Altersfreigabe",
6.226 - "", // TODO
6.227 - "", // TODO
6.228 - "", // TODO
6.229 - "", // TODO
6.230 - "", // TODO
6.231 - "", // TODO
6.232 - "", // TODO
6.233 - "", // TODO
6.234 - "", // TODO
6.235 - "", // TODO
6.236 - "", // TODO
6.237 - "", // TODO
6.238 - "", // TODO
6.239 - "", // TODO
6.240 - },
6.241 - { "years",
6.242 - "Jahre",
6.243 - "", // TODO
6.244 - "", // TODO
6.245 - "", // TODO
6.246 - "", // TODO
6.247 - "", // TODO
6.248 - "", // TODO
6.249 - "", // TODO
6.250 - "", // TODO
6.251 - "", // TODO
6.252 - "", // TODO
6.253 - "", // TODO
6.254 - "", // TODO
6.255 - "", // TODO
6.256 - "", // TODO
6.257 - },
6.258 - { "Fix EPG data",
6.259 - "EPG Daten korrigieren",
6.260 - "", // TODO
6.261 - "", // TODO
6.262 - "", // TODO
6.263 - "", // TODO
6.264 - "", // TODO
6.265 - "", // TODO
6.266 - "", // TODO
6.267 - "", // TODO
6.268 - "", // TODO
6.269 - "", // TODO
6.270 - "", // TODO
6.271 - "", // TODO
6.272 - "", // TODO
6.273 - "", // TODO
6.274 - },
6.275 -
6.276 - { NULL }
6.277 - };
6.278 -#endif
6.279 -
6.280 // --- cMenuSetupPremiereEpg ------------------------------------------------------------
6.281
6.282 class cMenuSetupPremiereEpg : public cMenuSetupPage {