diff options
-rwxr-xr-x | modules/python/usfm2osis.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/python/usfm2osis.py b/modules/python/usfm2osis.py index f8dcc9e..a6bbb00 100755 --- a/modules/python/usfm2osis.py +++ b/modules/python/usfm2osis.py @@ -1411,6 +1411,7 @@ def printUsage(): print(' -e ENCODING input encoding override (default is to read the USFM file\'s') print(' \\ide value or assume UTF-8 encoding in its absence)') print(' -h, --help print this usage information') + print(' -l LANGUAGE input language code - (default "und")') print(' -o FILENAME output filename (default is: <osisWork>.osis.xml)') print(' -r enable relaxed markup processing (for non-standard USFM)') print(' -s mode set book sorting mode: natural (default), alpha, canonical,') @@ -1511,7 +1512,16 @@ if __name__ == "__main__": relaxedConformance = True bookDict = dict(list(bookDict.items()) + list(addBookDict.items())) inputFilesIdx += 1 - + + if '-l' in sys.argv: + i = sys.argv.index('-l')+1 + if len(sys.argv) < i+1: + printUsage() + + language = sys.argv[i] + inputFilesIdx += 2 #increment 2, reflecting 2 args for -l + else: language = 'und' + if '-s' in sys.argv: i = sys.argv.index('-s')+1 if len(sys.argv) < i+1: @@ -1567,7 +1577,7 @@ if __name__ == "__main__": osisSegment[k]=v print('Assembling OSIS document') - osisDoc = '<osis xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.'+osisVersion+'.xsd">\n<osisText osisRefWork="Bible" xml:lang="und" osisIDWork="' + osisWork + '">\n<header>\n<work osisWork="' + osisWork + '"/>\n</header>\n' + osisDoc = '<osis xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.'+osisVersion+'.xsd">\n<osisText osisRefWork="Bible" xml:lang="' + language + '" osisIDWork="' + osisWork + '">\n<header>\n<work osisWork="' + osisWork + '"/>\n</header>\n' unhandledTags = set() for doc in usfmDocList: |