root/trunk/build/l10n/wrap.pl @ 3531

Revision 3531, 1.9 kB (checked in by fumiakiy, 9 months ago)

Merged sockfish to trunk. "svn merge -r3114:3527 http://code.sixapart.com/svn/movabletype/branches/sockfish/ ."

  • 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-2009 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# Movable Type (r) Open Source (C) 2005-2009 Six Apart, Ltd.
16# This program is distributed under the terms of the
17# GNU General Public License, version 2.
18#
19#
20# \$Id:\$
21
22package MT::L10N::$LANG;
23use strict;
24use MT::L10N;
25use MT::L10N::en_us;
26use vars qw( \@ISA \%Lexicon );
27\@ISA = qw( MT::L10N::en_us );
28
29## The following is the translation table.
30
31\%Lexicon = (
32EOF
33}
34
35my $tmpl;
36my $plugin = q();
37my %conv;
38my %pgconv;
39
40while (<>) {
41    if (/^\s*##\s*(.*)$/) {
42        $tmpl = $1;
43        if ( $tmpl =~ m!^plugins!
44          || $tmpl =~ m!^addons! ) {
45            my ($pg) = $tmpl =~ m!^(?:plugins|addons)/(.+?)/.+!;
46            %pgconv = () unless $pg eq $plugin;
47            $plugin = $pg;
48        }
49        else {
50            $plugin = q();
51        }
52        my $l = $_;
53        last if eof();
54        $_ = <>;
55        next if ($_ =~ /^\s*$/);
56        print $l;
57    }
58    if (/^[#\s]+'(.+)' => '(.*)',($|\s*\#)/) { # Now also reads empty/to be translated strings
59        my $base = $1; 
60        my $trans = $2;
61        if ( !exists($conv{$base}) && !exists($pgconv{$base}) ) {
62            print $_;
63            $words = wordcount($base);
64            $wc += $words unless ($trans);
65        }
66        if ( $plugin ) {
67            $pgconv{$base} = 1;
68        }
69        else {
70            $conv{$base} = 1;
71        }
72    }
73    else{
74        print $_;
75    }
76}
77
78END {
79    print <<EOF
80
81);
82
83## New words: $wc
84
851;
86EOF
87
88}
89sub wordcount {
90        my $l = shift;
91    $l =~ s/[`!"$%^&*()_+={[}\];:@~#,.<>?\\\/]/ /g; #`
92    $l =~ s/\ ([ei])\ ([ge])\ / $1.$2./g;
93    my @words = split(/\W*\s+\W*/, $l);         # see the Camel book p.39
94        return ($#words + 1);
95}
96
Note: See TracBrowser for help on using the browser.