diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/crossreferences/xreffix.pl | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/modules/crossreferences/xreffix.pl b/modules/crossreferences/xreffix.pl index 29248e8..d7ac2fc 100644 --- a/modules/crossreferences/xreffix.pl +++ b/modules/crossreferences/xreffix.pl @@ -37,20 +37,18 @@ ## sword-support@crosswire.org ######################################################################### -sub vs2osis { +use Sword; + - my $return = `vs2osisref "$_[0]" "$_[1]" $_[2]`; - $return =~ s/\n$//; - $return; -} -$version = "1.0"; +$version = "1.1"; $osisVersion = "2.1.1"; $date = '$Date: 2010-08-04 05:46:26 +0000 (Tue, 04 Aug 2009) $'; $rev = '$Rev: 231 $'; - +$mgr = new Sword::SWMgr(); +$module = $mgr->getModule('KJV'); if (scalar(@ARGV) < 2) { print "xreffix.pl -- fixes crossreferences in OSIS files where usfm2osis.pl has failed. version $version\nRevision $rev ($date)\nSyntax: xreffix.pl <input filename> [-o <output-file>] [-l <xreflocale>].\n"; @@ -72,6 +70,9 @@ elsif ($ARGV[3] eq "-l") { else { $locale = "en"; } + +Sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName($locale); + open (OUTF, ">", "$outputFilename") or die "Could not open file $outputFilename for writing."; open (INF, "<", $ARGV[0]); @@ -79,24 +80,28 @@ open (INF, "<", $ARGV[0]); close (INF); $c_book = "Gen"; -$c_chapter="1" +$c_chapter="1"; foreach (@data) { if (/xml:lang\=\"(.+?)\"/) { - $locale=$1; - print "This document is in the locale of ".$locale."\n"; - } + if ($locale ne $1) { + print "This document is in the locale of ".$1."\n"; + Sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName($1); + } + + } if (/<div\ type\=\"book\"\ osisID=\"(.+?)\">/) { $c_book=$1; print "\n"."Now working on ".$c_book."\n"; - } + } if (/<chapter\ sID\=\".*?\.([0-9]+)\"/) { $c_chapter=$1; print "."; - } - - s/<reference>(.*?)<\/reference>/&vs2osis($1,$c_book.$c_chapter,$locale)/eg; + } + my $scope= new Sword::VerseKey; + $scope->setText($c_book.$c_chapter); + s/<reference>(.*?)<\/reference>/Sword::VerseKey::convertToOSIS($1, $scope)/eg; } print (OUTF @data); close OUTF; |