diff options
author | Andreas Mair <amair.sob@googlemail.com> | 2005-10-04 14:15:11 +0200 |
---|---|---|
committer | Andreas Mair <amair.sob@googlemail.com> | 2005-10-04 14:15:11 +0200 |
commit | a935422b27fcfc8713c63033c419081b5731fcff (patch) | |
tree | 4fa4d7b68752c9c3b066a11ca7c3a58f22441954 /tools/tmplgettext | |
parent | 32e84da8cc92fc7c69e6ecbf6d937145018f96f2 (diff) | |
download | vdradmin-am-0.97-am3.4.1.tar.gz vdradmin-am-0.97-am3.4.1.tar.bz2 |
2005-10-04: 0.97-am3.4.1v0.97-am3.4.1
- Fixed some bugs:
-> Selected channel is remembered when editing AutoTimers (Reported by Scorp).
-> Recording streaming didn't work in some cases (Reported by several people @vdr-portal.de).
-> Recording commands didn't work in some cases (Reported by several people @vdr-portal.de).
-> Watch TV and remote control didn't work (Reported by several people @vdr-portal.de).
-> INFO button in prog_list2 didn't work.
-> Getting back from timer_new to prog_summary/prog_list/prog_list2 again scrolls to line with previously selected item (Reported by Scorp).
- Updated translations
- Fixed some more HTMLtidy warnings.
Diffstat (limited to 'tools/tmplgettext')
-rwxr-xr-x | tools/tmplgettext | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/tools/tmplgettext b/tools/tmplgettext new file mode 100755 index 0000000..5a756ab --- /dev/null +++ b/tools/tmplgettext @@ -0,0 +1,158 @@ +#!/usr/bin/perl + +# +# tmplgettext <regexp> <directories> +# +# Creates a gettext pot-template from any text template specified by <regexp> +# in <directories> (recursivly) +# +# Any text matching /<%! (.*) !%>/ (even across multiple lines) will be +# interpreted as a translatable strings like in gettext("foo") or _("foo"). +# +# e.g.: tmplgettext "^.*\.html$" ./templates >templates.pot +# +# Output goes to stdout. +# +# 04/2005 - Tobias Grimm <vdr@e-tobi.net> +# + +my $BASENAME; +BEGIN { + $BASENAME = $1; + unshift(@INC, $BASENAME . "../tools/lib/"); +} + +use String::Escape qw(printable); +use File::Find; + +my $START_TAG = "<%! "; +my $END_TAG = " !%>"; + +my $filePattern = ""; + +sub WritePotHeader +{ + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + localtime(time); + + print "# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +#, fuzzy +msgid \"\" +msgstr \"\" +\"Project-Id-Version: VDRAdmin-0.97-AM3.3\\n\" +\"Report-Msgid-Bugs-To: Andreas Mair <mail@andreas.vdr-developer.org>\\n\"\n"; + + # FIXME: Correctly set timezone + + printf "\"POT-Creation-Date: %4d-%02d-%02d %02d:%02d+0100\"\n", + $year + 1900, $mon + 1, $mday, $hour, $min; + + print "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\" +\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\" +\"Language-Team: LANGUAGE <LL@li.org>\\n\" +\"MIME-Version: 1.0\\n\" +\"Content-Type: text/plain; charset=CHARSET\\n\" +\"Content-Transfer-Encoding: 8bit\\n\"\n\n"; +} + +sub my_normalize { + my $text = shift; + $text =~ s/[\t\n]//g; + return printable($text); +} + +sub WritePotEntry +{ + my ($fileName, $lineNumber, $msgid) = @_; + my $escapedMsgid = my_normalize($msgid); + + print "#: $fileName:$lineNumber\n"; + print "msgid \"$escapedMsgid\"\n"; + print "msgstr \"\"\n\n"; +} + +sub ExtractMsgids +{ + my ($fileName, @fileContent) = @_; + my $text = ""; + my $isTextStarted = 0; + my $lineCounter = 0; + my $textStartLine; + + foreach my $line (@fileContent) + { + my $lookAhead; + + $lineCounter++; + + if ($isTextStarted = 1) + { + $text = $text . "\n"; + } + + for (my $index=0; $index < length($line); $index++) + { + $lookAhead = substr($line, $index, length($START_TAG)); + if ($lookAhead eq $START_TAG) + { + $index = $index + length($START_TAG); # skip whole tag + $isTextStarted = 1; + $textStartLine = $lineCounter; + $text = ""; + } + + $lookAhead = substr($line, $index, length($END_TAG)); + if ($lookAhead eq $END_TAG) + { + if ($isTextStarted) + { + $index = $index + length($END_TAG); # skip whole tag + if (length($text) > 0) + { + WritePotEntry($fileName, $textStartLine, $text); + } + $isTextStarted = 0; + } + } + + if ($isTextStarted) + { + $text = $text . substr($line, $index, 1); + } + } + } +} + +sub ProcessFile +{ + if ($File::Find::name =~ /$filePattern/) + { + open(HTML, "< $File::Find::name"); + my @fileContent = <HTML>; + close(HTML); + + ExtractMsgids($File::Find::name, @fileContent); + } +} + +# +# main() +# + +$filePattern = shift(@ARGV); + +WritePotHeader; + +find({no_chdir => 1, wanted => \&ProcessFile}, @ARGV); |