root/branches/release-29/build/l10n/wrap.pl @ 1308

Revision 1308, 1.9 kB (checked in by bsmith, 22 months ago)

Merging commits from release-28 changesets 1274 to 1306

  • Property svn:executable set to *
  • Property svn:keywords set to Id Revision
Line 
1#! /usr/bin/perl -w
2
3# Movable Type (r) Open Source (C) 2005-2008 Six Apart, Ltd.
4# This program is distributed under the terms of the
5# GNU General Public License, version 2.
6#
7# $Id$
8
9my $wc =0; # New: count the number of words left to translate!
10
11BEGIN {
12    my $LANG = $ARGV[0];
13    shift @ARGV unless (-e $LANG);
14    print <<EOF;
15# Copyright 2003-2008 Six Apart. This code cannot be redistributed without
16# permission from www.sixapart.com.
17#
18# \$Id:\$
19
20package MT::L10N::$LANG;
21use strict;
22use MT::L10N;
23use MT::L10N::en_us;
24use vars qw( \@ISA \%Lexicon );
25\@ISA = qw( MT::L10N::en_us );
26
27## The following is the translation table.
28
29\%Lexicon = (
30EOF
31}
32
33my $tmpl;
34my $plugin = q();
35my %conv;
36my %pgconv;
37
38while (<>) {
39    if (/^\s*##\s*(.*)$/) {
40        $tmpl = $1;
41        if ( $tmpl =~ m!^plugins!
42          || $tmpl =~ m!^addons! ) {
43            my ($pg) = $tmpl =~ m!^(?:plugins|addons)/(.+?)/.+!;
44            warn $pg;
45            %pgconv = () unless $pg eq $plugin;
46            $plugin = $pg;
47        }
48        else {
49            $plugin = q();
50        }
51        my $l = $_;
52        last if eof();
53        $_ = <>;
54        next if ($_ =~ /^\s*$/);
55        print $l;
56    }
57    if (/^[#\s]+'(.+)' => '(.*)',($|\s*\#)/) { # Now also reads empty/to be translated strings
58        my $base = $1; 
59        my $trans = $2;
60        if ( !exists($conv{$base}) && !exists($pgconv{$base}) ) {
61            print $_;
62            $words = wordcount($base);
63            $wc += $words unless ($trans);
64        }
65        if ( $plugin ) {
66            $pgconv{$base} = 1;
67        }
68        else {
69            $conv{$base} = 1;
70        }
71    }
72    else{
73        print $_;
74    }
75}
76
77END {
78    print <<EOF
79
80);
81
82## New words: $wc
83
841;
85EOF
86
87}
88sub wordcount {
89        my $l = shift;
90    $l =~ s/[`!"$%^&*()_+={[}\];:@~#,.<>?\\\/]/ /g; #`
91    $l =~ s/\ ([ei])\ ([ge])\ / $1.$2./g;
92    my @words = split(/\W*\s+\W*/, $l);         # see the Camel book p.39
93        return ($#words + 1);
94}
95
Note: See TracBrowser for help on using the browser.