|
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 | |
|---|
| 9 | my $wc =0; # New: count the number of words left to translate! |
|---|
| 10 | |
|---|
| 11 | BEGIN { |
|---|
| 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 | |
|---|
| 20 | package MT::L10N::$LANG; |
|---|
| 21 | use strict; |
|---|
| 22 | use MT::L10N; |
|---|
| 23 | use MT::L10N::en_us; |
|---|
| 24 | use vars qw( \@ISA \%Lexicon ); |
|---|
| 25 | \@ISA = qw( MT::L10N::en_us ); |
|---|
| 26 | |
|---|
| 27 | ## The following is the translation table. |
|---|
| 28 | |
|---|
| 29 | \%Lexicon = ( |
|---|
| 30 | EOF |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | my $tmpl; |
|---|
| 34 | my $plugin = q(); |
|---|
| 35 | my %conv; |
|---|
| 36 | my %pgconv; |
|---|
| 37 | |
|---|
| 38 | while (<>) { |
|---|
| 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 | |
|---|
| 77 | END { |
|---|
| 78 | print <<EOF |
|---|
| 79 | |
|---|
| 80 | ); |
|---|
| 81 | |
|---|
| 82 | ## New words: $wc |
|---|
| 83 | |
|---|
| 84 | 1; |
|---|
| 85 | EOF |
|---|
| 86 | |
|---|
| 87 | } |
|---|
| 88 | sub 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 | |
|---|