From ce9bde6b8348caeb1637371ad7834a26e3d504c5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 16 Jul 2005 23:02:33 +0000 Subject: [PATCH 1/1] Start i18n stuff. --- intl/Sesse::ExtractGettext.pm | 26 ++++++++++++++++++++++++++ intl/make-pot.pl | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 intl/Sesse::ExtractGettext.pm create mode 100644 intl/make-pot.pl diff --git a/intl/Sesse::ExtractGettext.pm b/intl/Sesse::ExtractGettext.pm new file mode 100644 index 0000000..857ee1f --- /dev/null +++ b/intl/Sesse::ExtractGettext.pm @@ -0,0 +1,26 @@ + +package Sesse::ExtractGettext; +use strict; +use warnings; +use Template::Directive; + +our @ISA = qw(Template::Directive); + +sub textblock { + my ($self, $text) = @_; + + while ($text =~ s/<(h[1-6]|p|td|th|title|input|span|li|_)[^>]*>(.*?)<\/\1>//s) { + my $text = $2; + $text =~ s/\n/\\n"\n"/g; + $text =~ s/(.)"(?!\n)/$1\\"/g; + + print "msgid \"$text\"\n"; + print "msgstr \"\"\n"; + print "\n"; + } + + return $self->SUPER::textblock($text); +} + + + diff --git a/intl/make-pot.pl b/intl/make-pot.pl new file mode 100644 index 0000000..a86d4cf --- /dev/null +++ b/intl/make-pot.pl @@ -0,0 +1,24 @@ +#! /usr/bin/perl +use Template; +require 'Sesse::ExtractGettext.pm'; + +my $template = Template->new({ FACTORY => 'Sesse::ExtractGettext' }); +my $date = `date +"%Y-%M-%d %H:%M%z"`; # pah :-) +chomp $date; + +print <<"EOF"; +# ccbs template file for $ARGV[0] +msgid "" +msgstr "" +"Project-Id-Version: ccbs\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: $date\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=utf-8\\n" +"Content-Transfer-Encoding: 8bit\\n" + +EOF + +my $eaten = ''; +$template->process($ARGV[0], $vars, \$eaten) +or die $template->error(); -- 2.39.2