Add words to the iPhone's built-in dictionary file.
This script requires Perl to be installed. Add the
CoreDev repo to Cydia to install Perl.
Code:
#!/usr/local/bin/perl
# This program will add words to the iPhone word database.
# Created by tatum, 04/02/2009
###############
# Define vars #
###############
$file = "/private/var/mobile/Library/Keyboard/dynamic-text.dat";
#########
# Usage #
#########
# If no args given, or "-h", print usage
if (@ARGV == 0 or $ARGV[0] eq '-h') {
&usage;
}
sub usage {
print <<EOF;
Usage:
dic -a <word> <another word>... - Adds <words> to iPhone dictionary file
dic -h - Displays this message
EOF
exit 1;
}
########
# Code #
########
if (($ARGV[0] eq "-a") && (@ARGV >= 2)) {
open(DICT, ">>$file") or die "Unable to open '$file': $!\n";
binmode DICT;
@current = <DICT>;
shift (@ARGV);
foreach $word (@ARGV) {
unless (grep(/^$word$/, @current)) {
print DICT $word;
} else {
die "\n'$word' already exists in '$file'.\n";
}
}
close(DICT);
} else {
&usage;
}
Example:
dic -a word1 word2 word3