# HG changeset patch # User nathan # Date 1201538391 -3600 # Node ID 3c10fdd8ccce3b9608c9a7e6d1e713d559d49692 # Parent 83fd6cf37084f210bec968fda2fef8c7575d24e8 use po2i18n for non-locale vdr diff -r 83fd6cf37084 -r 3c10fdd8ccce Makefile --- a/Makefile Mon Jan 28 17:22:15 2008 +0100 +++ b/Makefile Mon Jan 28 17:39:51 2008 +0100 @@ -82,24 +82,35 @@ PODIR = po I18Npot = $(PODIR)/$(PLUGIN).pot -I18Nmsgs = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo,$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file)))))) +I18Npots := $(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file)))) +ifeq ($(strip $(APIVERSION)),1.5.7) + I18Nmo = $(PLUGIN).mo +else + I18Nmo = vdr-$(PLUGIN).mo +endif LOCALEDIR = $(VDRDIR)/locale +I18Nmsgs := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(I18Npots))) + +HASLOCALE = $(shell grep -l 'I18N_DEFAULT_LOCALE' $(VDRDIR)/include/vdr/i18n.h) +ifeq ($(strip $(HASLOCALE)),) + OBJS += i18n.o +endif ### Targets: TARGETS = libvdr-$(PLUGIN).so -ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c) -TARGETS += i18n +ifneq ($(strip $(HASLOCALE)),) + TARGETS += i18n endif all: $(TARGETS) -.PHONY: i18n +.PHONY: i18n clean dist # Dependencies: MAKEDEP = $(CXX) -MM -MG DEPFILE = .dependencies -DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c)) +DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c))) $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h) @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@ @@ -114,7 +125,7 @@ $(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@ @cp $@ $(LIBDIR)/$@.$(APIVERSION) -$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR)) +$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c ) xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='' -o $@ $^ %.po: $(I18Npot) @@ -124,12 +135,15 @@ %.mo: %.po msgfmt -c -o $@ $< -$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo +$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo @mkdir -p $(dir $@) cp $< $@ i18n: $(I18Nmsgs) +i18n.c: $(PODIR)/*.po i18n-template.c po2i18n.pl + perl ./po2i18n.pl i18n.c + version.c: FORCE @echo >$@.new "/* this file will be overwritten without warning */"; \ echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \ @@ -147,7 +161,7 @@ clean: @-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~ - @-rm -f version.c + @-rm -f version.c i18n.c @-rm -f $(PODIR)/*.mo FORCE: diff -r 83fd6cf37084 -r 3c10fdd8ccce README.po2i18n --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.po2i18n Mon Jan 28 17:39:51 2008 +0100 @@ -0,0 +1,44 @@ + + po2i18n - Converter for po files + + +Written by: Udo Richter +Project's homepage: http://www.udo-richter.de/vdr/scripts.html#po2i18n + http://www.udo-richter.de/vdr/scripts.en.html#po2i18n + + + +About +-------------------------------------------------------------------------- +po2i18n is a perl script that generates an i18n.c file compatible to the i18n +system of VDR 1.2.0 - VDR 1.5.6, based on the .po files of VDR 1.5.7. This +allows plugins to transit to the translation system of VDR 1.5.7 while +maintaining compatibility to earlier versions. The script can be used manually +or automatically as part of the Makefile. + + +Use +-------------------------------------------------------------------------- +po2i18n.pl is a filter and can be used manually like this: + + ./po2i18n.pl < i18n-template.c > i18n.c + +The filter reads all relevant ./po/*.po files and writes the i18n strings +into the template file. Strings will be added between the following two lines: + + // START I18N + // END I18N + +See also the sample i18n.h and i18n-template.c file. Note that the phrases data +structure is encapsulated in #if VDRVERSNUM < 10507, so the i18n strings won't +be in the plugin file after 1.5.7. The call to RegisterI18n() of your plugin +should also be encapsulated like this. + +po2i18n can also generate the i18n.c file on the fly while compiling. The +changes to the Makefile are demonstrated by the included Makefile.diff sample. +With these changes, the i18n.c file will be generated on VDR up to 1.5.6, and +the whole gettext conversion is skipped. From 1.5.7 on, the i18n-template.c +file will be simply copied as a dummy, and the new locale system will run. + +As a drawback, the automatic .dependencies for i18n.c won't work. + diff -r 83fd6cf37084 -r 3c10fdd8ccce i18n-template.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i18n-template.c Mon Jan 28 17:39:51 2008 +0100 @@ -0,0 +1,18 @@ +/* + * Auto generated file, do not edit + * Will be overwritten/deleted without warning + * + * Edit the .po files if you want to update translations!! + */ + +#include "i18n.h" + +#if VDRVERSNUM < 10507 + +const tI18nPhrase Phrases[] = { +// START I18N +// END I18N + { NULL } + }; + +#endif diff -r 83fd6cf37084 -r 3c10fdd8ccce i18n.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i18n.h Mon Jan 28 17:39:51 2008 +0100 @@ -0,0 +1,36 @@ +/* + * PremiereEpg plugin to VDR (C++) + * + * (C) 2005-2008 Stefan Huelswitt + * + * This code is base on the commandline tool premiereepg2vdr + * (C) 2004-2005 by Axel Katzur software@katzur.de + * but has been rewritten from scratch + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html + */ + +#ifndef ___I18N_H +#define ___I18N_H + +#include + +#if APIVERSNUM < 10507 +extern const tI18nPhrase Phrases[]; +#define trNOOP(s) (s) +#endif + +#endif //___I18N_H diff -r 83fd6cf37084 -r 3c10fdd8ccce po2i18n.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/po2i18n.pl Mon Jan 28 17:39:51 2008 +0100 @@ -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; + } +} diff -r 83fd6cf37084 -r 3c10fdd8ccce premiereepg.c --- a/premiereepg.c Mon Jan 28 17:22:15 2008 +0100 +++ b/premiereepg.c Mon Jan 28 17:39:51 2008 +0100 @@ -1,7 +1,7 @@ /* * PremiereEpg plugin to VDR (C++) * - * (C) 2005-2007 Stefan Huelswitt + * (C) 2005-2008 Stefan Huelswitt * * This code is base on the commandline tool premiereepg2vdr * (C) 2004-2005 by Axel Katzur software@katzur.de @@ -32,14 +32,12 @@ #include #include #include +#include "i18n.h" #include "version.h" #if APIVERSNUM < 10401 #error You need at least VDR API version 1.4.1 for this plugin #endif -#if APIVERSNUM < 10507 -#define trNOOP(s) (s) -#endif //#define DEBUG //#define DEBUG2 @@ -89,254 +87,6 @@ FixEpg=0; } -// --- i18n -------------------------------------------------------------------- - -#if APIVERSNUM < 10507 -const tI18nPhrase Phrases[] = { - { "PremiereEPG", - "PremiereEPG", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Parses extended Premiere EPG data", - "Liest erweiterte Premiere EPG Daten ein", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "off", - "aus", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Tag option events", - "Options Events markieren", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Show order information", - "Bestellhinweise anzeigen", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Show rating information", - "Altersfreigaben anzeigen", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - - { "Ordernumber", - "Bestellnummer", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Price", - "Preis", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Ordering", - "Bestellen", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "SMS", - "SMS", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "WWW", - "WWW", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Rating", - "Altersfreigabe", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "years", - "Jahre", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - { "Fix EPG data", - "EPG Daten korrigieren", - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - "", // TODO - }, - - { NULL } - }; -#endif - // --- cMenuSetupPremiereEpg ------------------------------------------------------------ class cMenuSetupPremiereEpg : public cMenuSetupPage {