2 binmode STDOUT, ":utf8";
5 $target_cur = "$target_lang.txt";
6 $target_unused = "$target_lang.unused.txt";
7 $target_done = "$target_lang.done.txt";
8 $target_notyet = "$target_lang.notyet.txt";
9 $target_done_new = "$target_lang.done.new.txt";
10 $target_notyet_new = "$target_lang.notyet.new.txt";
16 if(-e $target_cur || -e $target_unused || -e $target_done_new || -e $target_notyet_new){
17 print "Error. Clean files first.\n";
22 open(my $fh, "<:utf8", $target_notyet);
27 if($_ =~ m/^(\r\n|\r|\n)$/){
31 $ja =~ s/(\r\n|\r|\n)$//;
33 $local =~ s/(\r\n|\r|\n)$//;
35 $current{$ja} = $local;
39 open(my $fh, "<:utf8", $target_done);
44 if($_ =~ m/^(\r\n|\r|\n)$/){
48 $ja =~ s/(\r\n|\r|\n)$//;
50 $local =~ s/(\r\n|\r|\n)$//;
52 $current{$ja} = $local;
59 push(@files, "/var/www/glyphwiki.org/index.cgi");
60 opendir($dh, "/home/kamichi/glyphwiki/") or die $!;
61 foreach(grep(/\.pl$/, readdir($dh))){
63 push(@files, "/home/kamichi/glyphwiki/$_");
71 open(my $fh, "<:utf8", $_);
74 if($_ =~ m/^[ \t]*([^\#]*[^ -~\r\n\t]+[^\#]*)(\#.*)?[\r\n]+$/){
75 if($_ !~ m/\#.*ja_mama/){
76 $cand{$1} .= $line.",";
85 foreach(sort({$cand{$a} <=> $cand{$b}} keys(%cand))){
86 if(exists($current{$_})){
87 $buffer1 .= ":".substr($cand{$_}, 0, length($cand{$_}) - 1)."\n$_\n$current{$_}\n";
88 $buffer3 .= ":".substr($cand{$_}, 0, length($cand{$_}) - 1)."\n$_\n$current{$_}\n";
89 delete($current2{$_});
91 $buffer2 .= ":".substr($cand{$_}, 0, length($cand{$_}) - 1)."\n$_\n$_\n";
92 $buffer3 .= ":".substr($cand{$_}, 0, length($cand{$_}) - 1)."\n$_\n$_\n";
95 $done .= "!".$fn."\n".$buffer1."\n";
96 $notyet .= "!".$fn."\n".$buffer2."\n";
97 $result .= "!".$fn."\n".$buffer3."\n";
101 foreach(sort({$current2{$a} <=> $current2{$b}} keys(%current2))){
102 $unused .= ":\n$_\n$current2{$_}\n";
105 open(my $fh, ">:utf8", $target_cur);
108 open(my $fh, ">:utf8", $target_done_new);
111 open(my $fh, ">:utf8", $target_notyet_new);
114 open(my $fh, ">:utf8", $target_unused);