Files
interactive/gms/KT/httpd/wwwroot/tts/TTXDictionary.pm
2026-08-07 17:38:18 +09:00

67 lines
1.4 KiB
Perl

package TTXDictionary;
#
# This module is a part of Trouble Ticket Express package
# http://www.troubleticketexpress.com
#
# COPYRIGHT: 2002-2006, United Web Coders
# http://www.unitedwebcoders.com
#
# $Revision: 253 $
# $Date: 2006-08-15 09:11:26 -0400 (Tue, 15 Aug 2006) $
#
$TTXDictionary::VERSION='2.22';
BEGIN {
$TTXDictionary::REVISION = '$Revision: 253 $';
if ($TTXDictionary::REVISION =~ /(\d+)/) {
$TTXDictionary::REVISION = $1;
}
};
use strict;
use CSV;
my %dictionary;
my $isLoaded;
my $uselang;
# ========================================================================= lang
sub lang {
my $uselang = $_[0];
}
# ========================================================================= load
sub load {
return 1 if $isLoaded;
my $cfg = TTXData::get('CONFIG');
my $dictname = 'dict'.(($uselang ne undef) ? "-$uselang":'').'.csv';
my $fn = $cfg->get('basedir')."/$dictname";
if (open(CSV, $fn)) {
foreach (my $line = <CSV>; $line ne undef; $line = <CSV>) {
chomp($line);
$line =~ s/(\r|\n)+$//;
my ($en, $trans) = CSVsplit($line);
$dictionary{$en} = $trans;
}
close CSV;
}
if ($dictionary{CHARSET} eq undef) {
$dictionary{CHARSET} = 'windows-1252';
}
$isLoaded = 1;
return 1;
}
# ==================================================================== translate
sub translate {
my $txt = $_[0];
load();
if (defined $dictionary{$txt}) {
$txt = $dictionary{$txt};
}
return $txt;
}
1;
#