The Non-English Field is where you put the non-english name of the category you are adding...Read the README file of the Mod more carefully!
1) Upload an old copy of your categories.db file that you were using prior to installing the Non-English Mod.
2) Then use the following script to add the delimiter to your categories.db file.
Code:
#!/usr/local/bin/perl
#Upgrade Database
#Put the default value of the new field here. Leave Blank for no default.
$field_default = "";
#Put the new field number here.
$new_field = "8";
#Put the last field number here.
$total_fields = "9";
# Database path...same as in db.cgi file
$db_script_path = '/path/to/cgi-bin/links/admin';
#Change these value to match your settings
#You may have to use the absolute path to your .cfg and .cgi file
require "/path/to/category.def";
#Rename database file
#You may have to use the absolute path to your second database file
$db_file_name2 = "/path/to/categories2.db";
#############################################
#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "<$db_script_path/$db_file_name") or print "Unable to open links database '$db_script_path/$db_file_name'. Reason: $!" and exit;
print "\tOpening output file . . .\n\n";
open (DBOUT, ">$db_script_path/$db_file_name2") or print "Unable to open $db_script_path/$db_file_name2. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit;
print "\n\n\tProcessing records...\n\n";
while (<DB> ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy fields into second database.
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old database file to new database file
for $i ($new_field .. $total_fields) {
$rec_out[$i + 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone...\n\n";
close DB;
close DBOUT;
print "\n\n";
print "Database saved it as $db_file_name2.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename '$db_file_name' to '$db_file_name2' to '$db_file_name' before using with DBMAN.\n";
print "It is recommend you save the original '$db_file_name' before renaming.\n\n";
print "Make sure that your new database is changed to 666.\n\n";
sub join_encode {
# --------------------------------------------------------
# Takes a hash (ususally from the form input) and builds one
# line to output into the database. It changes all occurrences
# of the database delimeter to '~~' and all newline chars to '``'.
my %hash = @_;
my ($tmp, $col, $output);
foreach $col (@db_cols) {
$tmp = $hash{$col};
$tmp =~ s/^\s+//g; # Trim leading blanks...
$tmp =~ s/\s+$//g; # Trim trailing blanks...
$tmp =~ s/\Q$db_delim\E/~~/og; # Change delimeter to ~~ symbol.
$tmp =~ s/\n/``/g; # Change newline to `` symbol.
$tmp =~ s/\r//g; # Remove Windows linefeed character.
$output .= $tmp . $db_delim; # Build Output.
}
chop $output; # remove extra delimeter.
$output .= "\n"; # add linefeed char.
return $output;
}
sub split_decode {
# --------------------------------------------------------
# Takes one line of the database as input and returns an
# array of all the values. It replaces special mark up that
# join_encode makes such as replacing the '``' symbol with a
# newline and the '~~' symbol with a database delimeter.
my ($input) = shift;
my (@array) = split (/\Q$db_delim\E/o, $input, $#db_cols+1);
foreach (@array) {
s/~~/$db_delim/g; # Retrieve Delimiter..
s/``/\n/g; # Change '' back to newlines..
}
return @array;
}
sub array_to_hash {
# --------------------------------------------------------
# Converts an array to a hash using db_cols as the field names.
#
my ($hit, @array) = @_;
my ($i);
return map { $db_cols[$i] => $array[$hit * ($#db_cols+1) + $i++] } @_;
}
to the absolute path in your server where the category.def and where your database files are located to create the categories2.db file.
3) Then replace the categories.db with categories2.db file.
4) Then go ahead and make the changes in your Non-English fields in your category records by modifying them via the LINKS MANAGER.
5) Then re-build your database.
Eliot Lee....