From a6138160501bf5c1bf42c5f16c6d0333d7b31e9d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 4 Dec 2011 14:36:37 +0100 Subject: Removed the '.pl' suffix from all scripts --- i18n-to-gettext.pl | 347 ----------------------------------------------------- 1 file changed, 347 deletions(-) delete mode 100755 i18n-to-gettext.pl (limited to 'i18n-to-gettext.pl') diff --git a/i18n-to-gettext.pl b/i18n-to-gettext.pl deleted file mode 100755 index 29d9345d..00000000 --- a/i18n-to-gettext.pl +++ /dev/null @@ -1,347 +0,0 @@ -#!/usr/bin/perl -w - -# Convert i18n texts to gettext -# -# Extracts all texts from the file i18n.c and creates language -# specific *.po files. -# -# Usage: i18n-to-gettext.pl -# -# See the main source file 'vdr.c' for copyright information and -# how to reach the author. -# -# $Id: i18n-to-gettext.pl 2.1 2009/10/18 14:07:49 kls Exp $ - -# How to convert an actual plugin: -# -# - If your code contains something like -# -# const char *Text = "Some text"; -# ... -# Function(tr(Text)); -# -# you need to enclose the text constant in trNOOP(...), as in -# -# const char *Text = trNOOP("Some text"); -# -# The actual usage of the tr() macro remains unchanged. -# -# - If you have comments following the texts in your i18n.c file -# that should be seen by the translators, move them from the -# i18n.c file into the file where the text is actually used, -# and mark them with the TRANSLATORS keyword, as in -# -# // TRANSLATORS: note the plural! -# Add(new cMenuEditIntItem( tr("Setup.EPG$Preferred languages"), ... -# -# - Fill in your email address in the line -# $MSGIDBUGS = "" ... -# below, so that users can reach you in case there is a problem -# with a message id. -# -# - Run this Perl script from within your plugin's source directory. -# This script will run 'xgettext' to extract all of your texts -# into a file named .pot. After that it will extract -# your existing i18n texts from the file i18n.c (or wherever you -# have defined them) and generate *.po files for all languages -# currently known by VDR. -# -# - Your Makefile will be automatically adjusted to allow for -# building the *.mo files necessary for supporting gettext(). -# Please check carefully whether the automatic adjustments have -# succeeded, though. The modified Makefile will be written to -# Makefile.new, so you can call this script any numer of times -# in case you need to do some fine tuning of your texts (especially -# adding some trNOOP() in case the script reports "missing phrases". -# Once you're done converting your plugin source to using gettext, -# rename Makefile.new to Makefile. -# -# - You may want to remove the old internationalized texts from your -# source. Usually this means removing the files i18n.[hc], stripping -# i18n.o from the OBJS variable in the Makefile and removing all -# '#include "i18n.h"' lines from the rest of your source files. -# These steps are not done automatically. - -# Check for the existence of a Makefile: - -die "Makefile not found!" unless (-f "Makefile"); - -# Determine the plugin name: - -$PLUGIN = `grep '^PLUGIN *=' Makefile | head -1` || die "can't find plugin name!"; -$PLUGIN =~ s/.*= *(.*)\n/$1/; -die "can't find plugin name!" unless ($PLUGIN); - -# Locate the file containing the texts: - -$I18NFILE = ""; -for ("i18n.c", "i18n.h", `ls *.c`) { # try i18n.[ch] explicitly first - chomp($f = $_); - if (-f $f && `grep tI18nPhrase $f`) { - $I18NFILE = $f; - last; - } - } -die "can't find internationalized texts!" unless ($I18NFILE); - -# Plugin specific information: - -$TITLE = "VDR plugin language source file"; -$COPYRIGHT = "2007 Klaus Schmidinger "; -$PACKAGE = "VDR"; -$VERSION = "1.5.7"; -$MSGIDBUGS = "" || die "enter your email address here"; # escape the '@', as in "user\@domain.tld" -$LANGUAGETEAM = ""; - -# Gettext environment: - -$XGETTEXT = "xgettext -C -cTRANSLATORS --no-wrap -F -k -ktr -ktrNOOP --msgid-bugs-address='$MSGIDBUGS'"; -$PODIR = "po"; -$POTFILE = "$PODIR/$PLUGIN.pot"; - -# Languages as known by VDR 1.5.6: - -@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" - ); - -@CHARSETS = ( - "ISO-8859-15", - "ISO-8859-15", - "ISO-8859-2", - "ISO-8859-15", - "ISO-8859-15", - "ISO-8859-1", - "ISO-8859-1", - "ISO-8859-1", - "ISO-8859-15", - "ISO-8859-2", - "ISO-8859-15", - "ISO-8859-7", - "ISO-8859-1", - "ISO-8859-2", - "ISO-8859-2", - "ISO-8859-1", - "ISO-8859-5", - "ISO-8859-2", - "ISO-8859-13", - "ISO-8859-15", - "ISO-8859-2", - "ISO-8859-9", - ); - -@TRANSLATORS = ( - "Klaus Schmidinger , 2000", - "Klaus Schmidinger , 2000", - "Miha Setina , 2000; Matjaz Thaler , 2003", - "Alberto Carraro , 2001; Antonio Ospite , 2003; Sean Carlos , 2005", - "Arnold Niessen , 2001; Hans Dingemans , 2003; Maarten Wisse , 2005", - "Paulo Lopes , 2001", - "Jean-Claude Repetto , 2001; Olivier Jacques , 2003; Gregoire Favre , 2003; Nicolas Huillard , 2005", - "Jørgen Tvedt , 2001; Truls Slevigen , 2002", - "Hannu Savolainen , 2002; Jaakko Hyvätti , 2002; Niko Tarnanen , 2003; Rolf Ahrenberg , 2003", - "Michael Rakowski , 2002", - "Ruben Nunez Francisco , 2002", - "Dimitrios Dimitrakos , 2002", - "Tomas Prybil , 2002; Jan Ekholm , 2003", - "Paul Lacatus , 2002; Lucian Muresan , 2004", - "Istvan Koenigsberger , 2002; Guido Josten , 2002", - "Marc Rovira Vall , 2003; Ramon Roca , 2003; Jordi Vilà , 2003", - "Vyacheslav Dikonov , 2004", - "Drazen Dupor , 2004; Dino Ravnic , 2004", - "Arthur Konovalov , 2004", - "Mogens Elneff , 2004", - "Vladimír Bárta , 2006", - "Oktay Yolgeçen , 2007" - ); - -@LASTTRANSLATOR = ( - "Klaus Schmidinger ", - "Klaus Schmidinger ", - "Matjaz Thaler ", - "Sean Carlos ", - "Maarten Wisse ", - "Paulo Lopes ", - "Nicolas Huillard ", - "Truls Slevigen ", - "Rolf Ahrenberg ", - "Michael Rakowski ", - "Ruben Nunez Francisco ", - "Dimitrios Dimitrakos ", - "Tomas Prybil ", - "Lucian Muresan ", - "Istvan Koenigsberger , Guido Josten ", - "Jordi Vilà ", - "Vyacheslav Dikonov ", - "Drazen Dupor ", - "Arthur Konovalov ", - "Mogens Elneff ", - "Vladimír Bárta ", - "Oktay Yolgeçen " - ); - -# 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/\/\*.*\*\///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 - if (/{ *(.*),/) { - $Original = $1; - $Index = 0; - } - elsif (/}/) { - } - else { - $Translated = $_; - $Translated =~ s/ *(.*),/$1/; - $Index++; - $Map{$Original}[$Index] = $Translated; - } - } -close(F); - -# Generate the .pot file: - -(mkdir($PODIR) || die "$PODIR: $!\n") unless -d $PODIR; - -system("$XGETTEXT -o $POTFILE *.c"); - -# Generate .po files for all languages: - -open(POT, $POTFILE) || die "$POTFILE: $!\n"; -@POT = ; -close(POT); - -for ($Index = 1; $LANGS[$Index]; $Index++) { - - $Authors = "# " . join("\n# ", split(/; */, $TRANSLATORS[$Index])) . "\n"; - - $POFILE = "$PODIR/$LANGS[$Index].po"; - open(PO, ">$POFILE") || die "$POFILE: $!\n"; - $msgid = ""; - for (@POT) { - next if (/^#, fuzzy$/); # skip the 'fuzzy' keyword - $msgid = $1 if (/^msgid (".+")/); - $date = $1 if (/POT-Creation-Date: (.*)\\n/); - $s = $_; - if (!$msgid) { - $s =~ s/SOME DESCRIPTIVE TITLE/$TITLE/; - $s =~ s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/$COPYRIGHT/; - $s =~ s/PACKAGE/$PACKAGE/; - $s =~ s/VERSION/$VERSION/; - $s = $Authors if (/FIRST AUTHOR/); - $s =~ s/YEAR-MO-DA HO:MI\+ZONE/$date/; - $s =~ s/FULL NAME /$LASTTRANSLATOR[$Index]/; - $s =~ s/LANGUAGE /$LANGUAGETEAM/; - $s =~ s/CHARSET/$CHARSETS[$Index]/; - } - else { - $s =~ s/""/$Map{$msgid}[$Index]/ if ($msgid && /^msgstr ""/ && defined $Map{$msgid}[$Index]); - $Used{$msgid} = 1; - } - print PO $s; - } - close(PO); - } - -# Report missing phrases: - -for (keys %Map) { - push(@Missing, "$_\n") unless $Used{$_}; - } - -if (@Missing) { - print "Missing phrases (may need to use trNOOP):\n\n"; - print sort(@Missing); - } - -# Adjust the Makefile: - -$MAKEI18N = q{### Internationalization (I18N): - -PODIR = po -LOCALEDIR = $(VDRDIR)/locale -I18Npo = $(wildcard $(PODIR)/*.po) -I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file)))))) -I18Npot = $(PODIR)/$(PLUGIN).pot - -%.mo: %.po - msgfmt -c -o $@ $< - -$(I18Npot): $(wildcard *.c) - xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<} . $MSGIDBUGS . q{>' -o $@ $^ - -%.po: $(I18Npot) - msgmerge -U --no-wrap --no-location --backup=none -q $@ $< - @touch $@ - -$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo - @mkdir -p $(dir $@) - cp $< $@ - -.PHONY: i18n -i18n: $(I18Nmsgs) - -}; - -open(OLD, "Makefile") || die "Makefile: $!"; -open(NEW, ">Makefile.new") || die "Makefile.new: $!"; -while () { - chomp; - if (/Targets:/) { - print NEW $MAKEI18N; - } - elsif (/^all:/) { - $_ .= " i18n"; - } - elsif (/^clean:/) { - $_ .= "\n\t\@-rm -f \$(PODIR)/*.mo \$(PODIR)/*.pot"; - } - print NEW "$_\n"; - } -close(NEW); -close(OLD); -- cgit v1.2.3