summaryrefslogtreecommitdiffstats
path: root/modules/conf/confmaker.pl
diff options
context:
space:
mode:
Diffstat (limited to 'modules/conf/confmaker.pl')
-rwxr-xr-xmodules/conf/confmaker.pl42
1 files changed, 37 insertions, 5 deletions
diff --git a/modules/conf/confmaker.pl b/modules/conf/confmaker.pl
index 99b42f8..07268f2 100755
--- a/modules/conf/confmaker.pl
+++ b/modules/conf/confmaker.pl
@@ -46,9 +46,10 @@ binmode (STDOUT,":utf8");
## Obtain arguments
if (scalar(@ARGV) < 1) {
print "\nconfmaker.pl -- - provides a initial conf file for a new module by analysing given OSIS xml file.\n";
- print "Syntax: confmaker.pl <osis XML file> [-o conf-output-file] [-i conf-input-file]\n";
+ print "Syntax: confmaker.pl <osis XML file> [-o conf-output-file] [-i conf-input-file] [-m] \n";
print "- Arguments in braces < > are required. Arguments in brackets [ ] are optional.\n";
print "- If no -o option is specified <STDOUT> is used.\n";
+ print "- if the -m option is used no -i option may be used. -m expects parametres added by other means, e.g. a makefile";
print "- The script can currently produce a valid conf file for OSIS bibles, but not for any other import formats.\n";
exit (-1);
}
@@ -70,6 +71,21 @@ if (@ARGV[$nextarg] eq "-i") {
@inputFile=`cat $inputFileName`;
}
+if (@ARGV[$nextarg] eq "-m") {
+ if ($inputFileName) {
+ print "You can not define both an input file and use the -m option, sorry...\n";
+ exit 1;}
+ $makefile=true;
+ $nextarg +=1;
+ }
+
+if (@ARGV[$nextarg] eq "-l") {
+ $language = "@ARGV[$nextarg+1]";
+ $nextarg += 2;
+ }
+
+
+
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($file);
@@ -82,8 +98,24 @@ my @elements = $doc->getElementsByTagName('osisText');
my $doc_name = @elements[0]->getAttribute('osisIDWork');
my $doc_type = @elements[0]->getAttribute('osisRefWork');
my $doc_lang = @elements[0]->getAttribute('xml:lang');
+my $doc_lang_name=I18N::LangTags::List::name($doc_lang);
+if ((length($language)==0) && (length($doc_lang_name)==0)) {
+ print STDERR $language."\n", $doc_lang."\n", $doc_lang_name."\n";
+ print STDERR "The language is undefined and no language was given on the commandline !\n";
+ exit;
+ }
+
+if ((length($language)>0) && (length($doc_lang_name)>0)) {
+ print STDERR "The language given on the commandline and the language of the document appear not to agree with each other !\n";
+ exit;
+ }
+
+if ((length($language)>0) && (length($doc_lang_name)==0)) {
+ $doc_lang_name = $language;
+ }
+
##GlobalOptionsFilter - prepare
@@ -183,12 +215,12 @@ if (@inputFile>0) {
print $_;
}
}
-else {
+elsif (!$makefile){
print "Version=1.0\n";
print "History=1.0 First release\n";
print "DistributionLicense=copyrighted. Do not distribute\n";
- print "Description=".$doc_name." Bible in ".I18N::LangTags::List::name($doc_lang)."\n";
- print "About=".$doc_name." Bible in ".I18N::LangTags::List::name($doc_lang)."\n";
- print "LCSH=".$doc_type.".".I18N::LangTags::List::name($doc_lang)."\n";
+ print "Description=".$doc_name." Bible in ".$doc_lang_name."\n";
+ print "About=".$doc_name." Bible in ".$doc_lang_name."\n";
+ print "LCSH=".$doc_type.".".$doc_lang_name."\n";
}