Mailing List Archive

svn commit: r191246 - in /spamassassin/trunk: MANIFEST.SKIP build/describe-to-po-file
Author: jm
Date: Fri Jun 17 19:11:33 2005
New Revision: 191246

URL: http://svn.apache.org/viewcvs?rev=191246&view=rev
Log:
add hack-in-progress, not for distribution yet though; converter from 'describe' lines in the rules dir to a GNU-standard .po file for translators

Added:
spamassassin/trunk/build/describe-to-po-file (with props)
Modified:
spamassassin/trunk/MANIFEST.SKIP

Modified: spamassassin/trunk/MANIFEST.SKIP
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/MANIFEST.SKIP?rev=191246&r1=191245&r2=191246&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST.SKIP (original)
+++ spamassassin/trunk/MANIFEST.SKIP Fri Jun 17 19:11:33 2005
@@ -107,3 +107,4 @@
^pod2ref
^masses/rule-qa/automc/
^sa-update$
+^build/describe-to-po-file$

Added: spamassassin/trunk/build/describe-to-po-file
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/describe-to-po-file?rev=191246&view=auto
==============================================================================
--- spamassassin/trunk/build/describe-to-po-file (added)
+++ spamassassin/trunk/build/describe-to-po-file Fri Jun 17 19:11:33 2005
@@ -0,0 +1,128 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $wantlang = shift @ARGV;
+
+my $localcharset = 'iso-8859-1';
+
+my %locales = (
+ 'en' => { },
+ 'local' => { }
+);
+
+foreach my $loc (qw(local en)) {
+ $locales{$loc}{desc} = { };
+ $locales{$loc}{tmpl} = { };
+ $locales{$loc}{tmpl}{unsafe_report} = '';
+ $locales{$loc}{tmpl}{report} = '';
+}
+
+while (<>) {
+ s/#.*$//g; s/^\s+//; s/\s+$//; next if /^$/;
+
+ # make all the foo-bar stuff foo_bar
+ 1 while s/^(\S+)-/$1_/g;
+ 1 while s/^(lang\s+\S+\s+\S+)-/$1_/g;
+
+ my $lang = '';
+ my $loc = 'en';
+
+ if (s/^lang\s+(\S+)\s+//) {
+ $lang = $1;
+ if ($lang ne $wantlang) { next; }
+ $loc = 'local';
+ }
+
+ if (/^report_charset\s+(\S+)$/) {
+ $localcharset = $1;
+ }
+
+ elsif (/^describe\s+(\S+)\s+(.*?)$/) {
+ $locales{$loc}{desc}{$1} = $2;
+ }
+
+ elsif (/^clear_report_template$/) {
+ $locales{$loc}{tmpl}{report} = '';
+ }
+ elsif (/^clear_unsafe_report_template$/) {
+ $locales{$loc}{tmpl}{unsafe_report} = '';
+ }
+ elsif (/^report\s+(.*?)$/) {
+ $locales{$loc}{tmpl}{report} .= "$1\n";
+ }
+ elsif (/^unsafe_report\s+(.*?)$/) {
+ $locales{$loc}{tmpl}{unsafe_report} .= "$1\n";
+ }
+
+ else {
+ next;
+ }
+}
+
+print q{
+# SpamAssassin PO file
+#
+# <@LICENSE>
+# Copyright 2004 Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# </@LICENSE>
+
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-05-13 18:38-0700\n"
+"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=} . $localcharset . q{\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+};
+
+foreach my $reptype (qw(report unsafe_report)) {
+ $locales{'local'}{tmpl}{$reptype} ||= '';
+
+ my $en = $locales{en}{tmpl}{$reptype} || '';
+ my $local = $locales{'local'}{tmpl}{$reptype} || '';
+
+ $en =~ s/\n/\"\n\"/gs;
+ $local =~ s/\n/\"\n\"/gs;
+
+ print qq{
+# $reptype block
+msgid ""
+"$en"
+msgstr ""
+"$local"
+ };
+}
+
+foreach my $rule (sort keys %{$locales{en}{desc}}) {
+ $locales{'local'}{desc}{$rule} ||= '';
+
+ my $en = $locales{en}{desc}{$rule};
+ my $local = $locales{'local'}{desc}{$rule};
+
+ print qq{
+# description for rule: $rule
+msgid "$en"
+msgstr "$local"
+ };
+}
+

Propchange: spamassassin/trunk/build/describe-to-po-file
------------------------------------------------------------------------------
svn:executable = *