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

Revision 1350, 1.9 kB (checked in by fumiakiy, 22 months ago)

Merging the latest of Release-28 to 29. svn merge -r1307:1332 http://code.sixapart.com/svn/movabletype/branches/release-28 .

  • 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            %pgconv = () unless $pg eq $plugin;
45            $plugin = $pg;
46        }
47        else {
48            $plugin = q();
49        }
50        my $l = $_;
51        last if eof();
52        $_ = <>;
53        next if ($_ =~ /^\s*$/);
54        print $l;
55    }
56    if (/^[#\s]+'(.+)' => '(.*)',($|\s*\#)/) { # Now also reads empty/to be translated strings
57        my $base = $1; 
58        my $trans = $2;
59        if ( !exists($conv{$base}) && !exists($pgconv{$base}) ) {
60            print $_;
61            $words = wordcount($base);
62            $wc += $words unless ($trans);
63        }
64        if ( $plugin ) {
65            $pgconv{$base} = 1;
66        }
67        else {
68            $conv{$base} = 1;
69        }
70    }
71    else{
72        print $_;
73    }
74}
75
76END {
77    print <<EOF
78
79);
80
81## New words: $wc
82
831;
84EOF
85
86}
87sub wordcount {
88        my $l = shift;
89    $l =~ s/[`!"$%^&*()_+={[}\];:@~#,.<>?\\\/]/ /g; #`
90    $l =~ s/\ ([ei])\ ([ge])\ / $1.$2./g;
91    my @words = split(/\W*\s+\W*/, $l);         # see the Camel book p.39
92        return ($#words + 1);
93}
94
Note: See TracBrowser for help on using the browser.