root/trunk/build/l10n/diff.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
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
9use strict;
10use Getopt::Long;
11
12my ($file1, $file2, $file3);
13my (%conv1, %conv2);
14my (%conv1_lc, %conv2_lc);
15
16GetOptions( 'old:s' => \$file1,
17            'target:s' => \$file2,
18            'new:s' => \$file3,
19);
20
21# print "## old: $file1 new: $file2 \n";
22print "\n\t## phrases from previous version.\n";
23
24open FH, $file1;
25while (<FH>) {
26    next if (/^\s*#/);
27    if ($_ =~ /^\s*(['"])(.+)\1\s*=>\s*(['"])(.+)\3,/) {
28            # print STDERR $2, "\n";
29            $conv1{$2} = $4;
30            $conv1_lc{lc $2} = $4;
31    }
32}
33close FH;
34
35open my $n, '>', $file3;
36
37open FH, $file2;
38while (<FH>) {
39    if (/^\s*#/) {
40        print $n "\n$_";
41        next;
42    }
43    if ($_ =~ /^\s*#?\s*(['"])(.+)\1\s*=>\s*(['"])(.*)\3,/) {
44            # print STDERR $2, "\n";
45        unless (exists $conv2{$2}) {
46            print $n $_;
47                $conv2{$2} = $4 || q();
48                $conv2_lc{lc $2} = $4 || q();
49        }
50    }
51}
52close FH;
53
54close $n;
55
56my %check;
57
58foreach my $p (keys %conv1) {
59    if ($conv1{$p} eq $conv2{$p}) {
60        $check{$p} = 1;
61    } elsif ($conv2{$p} && $conv1{$p} ne $conv2{$p}) {
62        # printf "\t'%s' => '%s',  # modified from '%s'\n", $p, $conv2{$p}, $conv1{$p};
63        $check{$p} = 1;
64    } elsif ($conv2_lc{lc $p}) {
65        # printf "\t'%s' => '%s',  # changed UPPER/LOWER '%s'\n", $p, $conv2_lc{lc $p}, $conv1_lc{lc $p};
66        $check{$p} = 1;
67        $check{lc $p} = 1;
68    } elsif (!exists($conv2{$p})) {
69        # printf "\t'%s' => '%s',  # only old. \n", $p, $conv1{$p};
70        my $q = "'";
71        if ($p =~ /\\[a-z]/) {
72            $q = '"';
73        }
74        printf "\t$q%s$q => '%s',\n", $p, $conv1{$p};
75    }
76}
77
78# print "\n\n# only in new\n\n";
79# foreach my $p (sort keys %conv2) {
80#    unless ($check{$p} || $check{lc $p}) {
81#        printf "\t'%s' => '%s',\n", $p, $conv2{$p};
82#     }
83# }
84
851;
Note: See TracBrowser for help on using the browser.