Spellchecking
Get translations from bazaar (see README.development in ankiqt source code from Git). Create a file ankispell.pl in any of directories above the one from bazaar. On Unix systems, execute chmod u+x ankispell.pl to make the file executable. Run the script passing language code as the argument (for German ./ankispell.pl de, for Chinese ./ankispell.pl zh_CN) and copy contents of libanki.txt and ankiqt.txt (they would be created in the same directory where the script resides) to OpenOffice Writer or run aspell -c on them.
#!/usr/bin/perl
use strict;
if ($#ARGV != 0) {
die "usage: $0 <language code>";
}
my $lang = $ARGV[0];
process(findfile(".*ankiqt/$lang.po"), 'libanki.txt');
process(findfile(".*libanki/$lang.po"), 'ankiqt.txt');
sub findfile {
my ($path) = @_;
my $res = `find . -path $path`;
my @res_arr = split /\n+/, $res;
if ($#res_arr < 0) {
die "cannot find $path";
}
if ($#res_arr > 0) {
die "error: more than one result: $res";
}
return $res_arr[0];
}
sub process {
my($infile, $outfile) = @_;
open(IN,$infile) or die "cannot open $infile";
my @lines = <IN>;
my $whole = join '', @lines;
$whole =~ s/^.*(X-Generator|X-Launchpad-Export-Date)/$1/sg;
$whole =~ s/(X-Generator|X-Launchpad-Export-Date).*//m;
$whole =~ s/^#.*//mg;
$whole =~ s/msgid "".*?msgstr ""//sg;
$whole =~ s/msgid.*//mg;
$whole =~ s/^msgstr(?:\[\d+\])? "(.*)"$/$1/mg;
$whole =~ s/^"(.*)"$/$1/mg;
$whole =~ s/\\n//g;
$whole =~ s/ *<[^<>]+> */E!E/sg;
$whole =~ s/^E!E//gm;
$whole =~ s/E!E(\.)/$1/gm;
$whole =~ s/(E!E)+/ /g;
$whole =~ s/ / /g;
$whole =~ s/ *%\([^()%]+\)[ds]/ 44/sg;
$whole =~ s/ *%[sd]/ 55/g;
$whole =~ s/\r\n/\n/g;
$whole =~ s/\n\r/\n/g;
$whole =~ s/\n{2,}/\n\n/g;
$whole =~ s/&(\w)/$1/g;
$whole =~ s/^ +//mg;
open(OUT,">$outfile");
print OUT $whole;
close(OUT);
print "wrote $lang to $outfile\n";
}