static void Main(string[] args) { Logit.useConsole = true; RecoverOsisData oz; if (args.Length < 2) { Console.WriteLine(@"Syntax: imposis2xml.exe infile xmlfile [logname] infile = file written by mod2imp.exe or an OSIS file like the KJV2006 example xmlfile = xml file for further parsing logname = name of log text file"); oz = new RecoverOsisData(); oz.readImpOsis(@"C:\Users\Kahunapule\Documents\tmp\Wycliffe.imp", @"C:\Users\Kahunapule\Documents\tmp\Wycliffe.usfx"); Logit.CloseFile(); } else { if (args.Length >= 3) { Logit.OpenFile(args[2]); } Console.WriteLine("imposis2xml " + args[0] + " " + args[1]); oz = new RecoverOsisData(); oz.readImpOsis(args[0], args[1]); Logit.CloseFile(); } }
private void convertButton_Click(object sender, System.EventArgs e) { Logit.OpenFile("WordSendLog.txt"); Logit.GUIWriteString = new StringDelegate(WriteToStatusListBox); Logit.WriteLine("Sorry, this program is still under construction."); Logit.CloseFile(); }
static void Main(string[] args) { int i; bool showBanner = false; string logName = "WordSendLog.txt"; string inName = ""; string outName = ".sfm"; // string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA")+ // "\\SIL\\WordSend\\joboptions.xml"; Logit.useConsole = true; for (i = 0; i < args.Length; i++) { // Scan the command line string s = args[i]; if ((s != null) && (s.Length > 0)) { if ((s[0] == '-') && (s.Length > 1)) { // command line switch: take action switch (Char.ToLower(s[1])) { case 'o': // Set output file name outName = SFConverter.GetOption(ref i, args); break; case 'i': // Set input file name inName = SFConverter.GetOption(ref i, args); break; case 'l': // Set log name logName = SFConverter.GetOption(ref i, args); break; case '-': case 'h': case '?': showBanner = true; break; default: Logit.WriteLine("Unrecognized command line switch: " + args[i]); showBanner = true; break; } } else if (inName == "") { inName = args[i]; } } } Logit.OpenFile(logName); Logit.WriteLine("\nWordSend project usfx2usfm compiled " + Version.date); if (inName == "") { showBanner = true; } else { Logit.WriteLine("Input file name is " + inName + "; output suffx is " + outName); // Something to refactor: make this line not required. // SFConverter.jobIni = new XMLini(jobOptionsName); // Here we instantiate the object that does most of the work. SFConverter.scripture = new Scriptures(); // Write out the USFM file SFConverter.scripture.USFXtoUSFM(inName, Path.GetDirectoryName(outName), Path.GetFileName(outName)); } if (showBanner) { Logit.WriteLine(""); Logit.WriteLine(Version.copyright); Logit.WriteLine(""); Logit.WriteLine(Version.contact); Logit.WriteLine(@" Syntax: usfx2usfm [-o Output] [-?] [-l logname] [-i] inputfile Output = output USFM path and file name suffix default is .sfm book code will be added, i. e. pdg.sfm -> MATpdg.sfm and subdir\eng.sfm -> subdir\MATeng.sfm logname is name of log file to write, default is WordSendLog.txt -h or -? = show this information. inputfile = name of USFX file to convert to USFM File names with embedded spaces must be surrounded by quotes. Do not use - as the first character of a path or file name. "); Logit.CloseFile(); } }
public void WriteTheModule() { string about; // licenseHtml or contents of about.inc in input project directory if (String.IsNullOrEmpty(globe.projectOptions.fcbhId)) { return; } int i; if ((globe.projectOptions.languageId.Length < 3) || (globe.projectOptions.translationId.Length < 3)) { return; } string UsfxPath = Path.Combine(globe.outputProjectDirectory, "usfx"); string browserBiblePath = Path.Combine(globe.outputProjectDirectory, "browserBible"); string browserBibleCssFileName; // Using latin.css for ALL projects marked as having a Latin script, regardless of exclusive use of common characters or not per Ken Bitgood 20 April 2016. // Reversed 15 Dec 2018 due to problems with NASB display. if (globe.projectOptions.commonChars) { browserBibleCssFileName = "latin.css"; } else { browserBibleCssFileName = globe.projectOptions.customCssFileName; } Utils.EnsureDirectory(browserBiblePath); if (String.IsNullOrEmpty(globe.projectOptions.fcbhId)) { MessageBox.Show("Missing FCBHID for " + globe.projectOptions.translationId); globe.projectOptions.fcbhId = globe.projectOptions.translationId; } if (!Directory.Exists(UsfxPath)) { MessageBox.Show(UsfxPath + " not found!", "ERROR"); return; } if (Directory.Exists(browserBiblePath)) { // Delete any old files in this directory. Utils.DeleteDirectory(browserBiblePath); } Utils.EnsureDirectory(browserBiblePath); string browserBibleCss = Path.Combine(browserBiblePath, browserBibleCssFileName); Utils.DeleteFile(browserBibleCss); // Always get the browser Bible CSS file from BibleConv/browserBiblecss/ with the same file name as the current custom CSS file name used for simple HTML. string browserBiblecssDir = Path.Combine(globe.dataRootDir, "browserBiblecss"); string specialCss = Path.Combine(browserBiblecssDir, browserBibleCssFileName); if (File.Exists(specialCss)) { File.Copy(specialCss, browserBibleCss); } string fallbackCss = Path.Combine(browserBiblecssDir, "fallback.css"); if (File.Exists(fallbackCss)) { File.Copy(fallbackCss, Path.Combine(browserBiblePath, "fallback.css")); } string aboutFile = Path.Combine(globe.inputProjectDirectory, "about.inc"); if (File.Exists(aboutFile)) { StreamReader sr = new StreamReader(aboutFile); about = globe.expandPercentEscapes(sr.ReadToEnd()); sr.Close(); } else { about = globe.copyrightPermissionsStatement(); } string sqlDir = Path.Combine(globe.outputProjectDirectory, "sql"); Utils.EnsureDirectory(sqlDir); usfx2BrowserBible toBrowserBible; toBrowserBible = new usfx2BrowserBible(); toBrowserBible.projectOptions = globe.projectOptions; toBrowserBible.projectOutputDir = globe.outputProjectDirectory; toBrowserBible.stripPictures = true; DateTime srcDate = globe.sourceDate; // Bring local to avoid potential exception in marshall-by-reference class toBrowserBible.indexDateStamp = "This module was generated by <a href='http://eBible.org'>eBible.org</a> on " + DateTime.UtcNow.ToString("d MMM yyyy") + " from source files dated " + srcDate.ToString("d MMM yyyy" + "."); if (!String.IsNullOrEmpty(certified)) { StreamReader sr = new StreamReader("/home/kahunapule/sync/doc/Electronic Scripture Publishing/ebible_certified_sm.b64"); string cert = sr.ReadToEnd(); sr.Close(); File.Copy(certified, Path.Combine(browserBiblePath, "eBible.org_certified.jpg")); toBrowserBible.indexDateStamp = String.Format("{0}<br /><a href='http://eBible.org/certified/' target='_blank'><img src='data:image/png;base64,{1}'>", toBrowserBible.indexDateStamp, cert); } toBrowserBible.CrossRefToFilePrefixMap = globe.projectOptions.CrossRefToFilePrefixMap; string usfxFilePath = Path.Combine(UsfxPath, "usfx.xml"); string orderFile = Path.Combine(globe.inputProjectDirectory, "bookorder.txt"); if (!File.Exists(orderFile)) { orderFile = SFConverter.FindAuxFile("bookorder.txt"); } StringBuilder localNumbers = new StringBuilder("\"numbers\":["); for (i = 0; i < 150; i++) { localNumbers.Append("\"" + fileHelper.LocalizeDigits(i.ToString()) + "\","); } localNumbers.Append("\"" + fileHelper.LocalizeDigits("150") + "\"],"); toBrowserBible.country = globe.projectOptions.country; toBrowserBible.countryCode = globe.projectOptions.countryCode; toBrowserBible.bookInfo.ReadPublicationOrder(orderFile); toBrowserBible.MergeXref(Path.Combine(globe.inputProjectDirectory, "xref.xml")); toBrowserBible.sourceLink = globe.expandPercentEscapes("<a href=\"http://%h/%t\">%v</a>"); toBrowserBible.textDirection = globe.projectOptions.textDir; toBrowserBible.languageNameInEnglish = globe.projectOptions.languageNameInEnglish; toBrowserBible.languageNameInVernacular = globe.projectOptions.languageName; toBrowserBible.traditionalAbbreviation = globe.projectOptions.translationTraditionalAbbreviation; toBrowserBible.englishDescription = globe.projectOptions.EnglishDescription; toBrowserBible.customCssName = browserBibleCssFileName; toBrowserBible.numbers = localNumbers.ToString(); toBrowserBible.fcbhAudioNt = globe.projectOptions.fcbhAudioNT; toBrowserBible.fcbhAudioOt = globe.projectOptions.fcbhAudioOT; toBrowserBible.fcbhDramaNt = globe.projectOptions.fcbhDramaNT; toBrowserBible.fcbhDramaOt = globe.projectOptions.fcbhDramaOT; toBrowserBible.fcbhPortion = globe.projectOptions.fcbhAudioPortion; toBrowserBible.coverName = Path.GetFileName(globe.preferredCover); string coverPath = Path.Combine(browserBiblePath, toBrowserBible.coverName); File.Copy(globe.preferredCover, coverPath, true); string covertnpng = Path.Combine(browserBiblePath, "covertn.png"); string covertnb64 = Path.Combine(browserBiblePath, "covertn.b64"); fileHelper.RunCommand(String.Format("shrinkcover {0} {1} {2}", coverPath, covertnpng, covertnb64)); toBrowserBible.b64CoverName = covertnb64; if ((globe.er != null) && (globe.er.countries != null)) { toBrowserBible.countries = globe.er.countries; } if (globe.projectOptions.commonChars) { toBrowserBible.preferredFont = "latin"; } else { toBrowserBible.preferredFont = globe.projectOptions.fontFamily; } toBrowserBible.shortTitle = globe.projectOptions.shortTitle; toBrowserBible.fcbhId = globe.projectOptions.fcbhId; toBrowserBible.dialectCode = globe.projectOptions.languageId + globe.projectOptions.dialect + globe.projectOptions.script; toBrowserBible.script = globe.projectOptions.script; string sqlTranslationId = globe.projectOptions.translationId.Replace("-", "_"); toBrowserBible.sqlTableName = sqlTranslationId + "_isvl"; toBrowserBible.sqlFileName = Path.Combine(Path.Combine(globe.outputProjectDirectory, "sql"), globe.projectOptions.translationId + "_isvl.sql"); toBrowserBible.langCodes = globe.languageCodes; toBrowserBible.xrefCall.SetMarkers(globe.projectOptions.xrefCallers); toBrowserBible.footNoteCall.SetMarkers(globe.projectOptions.footNoteCallers); toBrowserBible.redistributable = globe.projectOptions.redistributable; toBrowserBible.projectInputDir = globe.inputProjectDirectory; toBrowserBible.ConvertUsfxToHtml(usfxFilePath, browserBiblePath, globe.projectOptions.vernacularTitle, globe.projectOptions.languageId, globe.projectOptions.translationId, globe.projectOptions.chapterLabel, globe.projectOptions.psalmLabel, "<a href='copyright.htm'>" + usfxToHtmlConverter.EscapeHtml(globe.shortCopyrightMessage) + "</a>", globe.expandPercentEscapes(globe.projectOptions.homeLink), globe.expandPercentEscapes(globe.projectOptions.footerHtml), globe.expandPercentEscapes(globe.projectOptions.indexHtml), about, globe.projectOptions.ignoreExtras, globe.projectOptions.goText); ci = new CreateIndex(); ci.MakeJsonIndex(Path.Combine(Path.Combine(globe.outputProjectDirectory, "search"), "verseText.xml"), Path.Combine(browserBiblePath, "index"), Path.Combine(sqlDir, sqlTranslationId + "_conc.sql")); ci.MakeLemmaIndex(Path.Combine(Path.Combine(globe.outputProjectDirectory, "search"), "verseText.lemma"), Path.Combine(browserBiblePath, "indexlemma")); string fontsDir = Path.Combine(browserBiblePath, "fonts"); fileHelper.EnsureDirectory(fontsDir); string fontSource = Path.Combine(globe.dataRootDir, "fonts"); string fontName = globe.projectOptions.fontFamily.ToLower().Replace(' ', '_'); fileHelper.CopyFile(Path.Combine(fontSource, fontName + ".ttf"), Path.Combine(fontsDir, fontName + ".ttf")); fileHelper.CopyFile(Path.Combine(fontSource, fontName + ".woff"), Path.Combine(fontsDir, fontName + ".woff")); fileHelper.CopyFile(Path.Combine(fontSource, fontName + ".eot"), Path.Combine(fontsDir, fontName + ".eot")); Utils.DeleteFile(covertnpng); Utils.DeleteFile(covertnb64); Logit.CloseFile(); if (Logit.loggedError) { globe.projectOptions.lastRunResult = false; } if (Logit.loggedWarning) { globe.projectOptions.warningsFound = true; } }
static void Main(string[] args) { int i; bool showBanner = false; string logName = "usfx2mosislog.txt"; string inName = "usfx.xml"; string outName = "mosis.xml"; string ethnologueCode = String.Empty; string translationId = String.Empty; Logit.useConsole = true; for (i = 0; i < args.Length; i++) { // Scan the command line string s = args[i]; if ((s != null) && (s.Length > 0)) { if ((s[0] == '-') && (s.Length > 1)) { // command line switch: take action switch (Char.ToLower(s[1])) { case 'o': // Set output file name outName = SFConverter.GetOption(ref i, args); break; case 'i': // Set input file name inName = SFConverter.GetOption(ref i, args); break; case 'l': // Set log name logName = SFConverter.GetOption(ref i, args); break; case 't': translationId = SFConverter.GetOption(ref i, args); break; case '-': case 'h': case '?': case '/': showBanner = true; break; default: Logit.WriteLine("Unrecognized command line switch: " + args[i]); showBanner = true; break; } } else if (inName == "") { inName = args[i]; } } } Logit.OpenFile(logName); if (showBanner) { Logit.WriteLine(""); Logit.WriteLine("This is part of Haiola open source software."); Logit.WriteLine("Please see http://haiola.org for copyright information."); Logit.WriteLine(@" Syntax: usfx2usfm [-t translationId] [-o Output] [-?] [-l logname] [-i] [inputfile] translationId = unique translation identifier default is Ethnologue language code specified in usfx file Output = output USFM path and file name suffix default is mosis.xml logname is name of log file to write, default is usfx2mosislog.txt -h or -? = show this information. inputfile = name of USFX file to convert to USFM default is usfx.xml File names with embedded spaces must be surrounded by quotes. Do not use - as the first character of a path or file name. "); } else { Logit.WriteLine(DateTime.Now.ToString()); Logit.WriteLine("Input USFX: " + inName + "; output MOSIS: " + outName); usfxToMosisConverter toMosis = new usfxToMosisConverter(); toMosis.translationId = translationId; toMosis.revisionDateTime = DateTime.Now; toMosis.languageCode = String.Empty; toMosis.vernacularTitle = toMosis.contentCreator = toMosis.contentContributor = String.Empty; toMosis.englishDescription = toMosis.lwcDescription = toMosis.printPublisher = String.Empty; toMosis.ePublisher = toMosis.languageName = toMosis.dialect = String.Empty; toMosis.vernacularLanguageName = toMosis.copyrightNotice = String.Empty; toMosis.rightsNotice = String.Empty; toMosis.langCodes = new LanguageCodeInfo(); toMosis.ConvertUsfxToMosis(inName, outName); } Logit.CloseFile(); }
static void Main(string[] args) { bool showBanner = true; bool showHelp = false; string logName = "WordSendLog.txt"; string inName = ""; string outName = ""; int i; string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA") + "\\SIL\\WordSend\\joboptions.xml"; SFConverter.jobIni = new XMLini(jobOptionsName); Logit.useConsole = true; for (i = 0; i < args.Length; i++) { // Scan the command line string s = args[i]; if ((s != null) && (s.Length > 0)) { if (((s[0] == '-') || (s[0] == '/')) && (s.Length > 1)) { // command line switch: take action switch (Char.ToLower(s[1])) { case 'n': // No banner display showBanner = false; break; case 'o': // Set output file name outName = SFConverter.GetOption(ref i, args); break; case 'i': // Set input file name inName = SFConverter.GetOption(ref i, args); break; case 'l': // Set log name logName = SFConverter.GetOption(ref i, args); break; case '?': case 'h': case '-': showBanner = true; showHelp = true; break; default: Logit.WriteLine("Unrecognized command line switch: " + args[i]); break; } } else { if (inName == "") { inName = s; } else { if (outName == "") { outName = s; } else { showBanner = true; showHelp = true; } } } } } SFConverter.scripture = new Scriptures(); Logit.OpenFile(logName); if (showBanner) { Logit.WriteLine("\nWordSend project extract_usfx compiled " + Version.date); Logit.WriteLine(""); Logit.WriteLine(Version.copyright); Logit.WriteLine(""); Logit.WriteLine(Version.contact); } if ((outName.Length < 1) || (inName.Length < 1)) { showHelp = true; } if (showHelp) { Logit.WriteLine(@" Syntax: sf2word [-l logname] [-h] [-n] [-i] inputfile [-o] outputfile logname = log file name (default is WordSendLog.txt) -h = show this information then exit -n = supress banner inputfile = Microsoft Word XML file that has embedded USFX outputfile = name of USFX file to write "); Logit.CloseFile(); return; } Logit.WriteLine("Auxilliary files read."); SFConverter.scripture.ExtractUSFX(inName, outName); Logit.WriteLine("Done."); Logit.CloseFile(); }
static void Main(string[] args) { int i; bool showBanner = true; string outName = ""; string logName = "WordSendLog.txt"; string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA") + "\\SIL\\WordSend\\joboptions.xml"; string templateName = ""; ArrayList fileSpecs = new ArrayList(127); Logit.useConsole = true; for (i = 0; i < args.Length; i++) { // Scan the command line string s = args[i]; if ((s != null) && (s.Length > 0)) { if (((s[0] == '-') || (s[0] == '/')) && (s.Length > 1)) { // command line switch: take action switch (Char.ToLower(s[1])) { case 'j': // Job options file name jobOptionsName = SFConverter.GetOption(ref i, args); break; case 'n': // No banner display showBanner = false; break; case 'o': // Set output file name outName = SFConverter.GetOption(ref i, args); break; case 't': // Set template file name templateName = SFConverter.GetOption(ref i, args); break; case 'l': // Set log name logName = SFConverter.GetOption(ref i, args); break; case '?': case 'h': case '-': showBanner = true; break; default: Logit.WriteLine("Unrecognized command line switch: " + args[i]); break; } } else { fileSpecs.Add(args[i]); } } } Logit.OpenFile(logName); Logit.WriteLine("\nWordSend project sf2word compiled " + Version.date); if (showBanner) { Logit.WriteLine(""); Logit.WriteLine(Version.copyright); Logit.WriteLine(""); Logit.WriteLine(Version.contact); Logit.WriteLine(@" Syntax: sf2word [-o Output] [-j Job] [-t Template] [-n] [-?] [-l logname] filespec(s) Output = output WordML file name Job = name of XML job options file created with usfm2word.exe. Template = example WordML document with the required style definitions -n = don't display copyright and banner information. -? = cancel previous /n and show this information. -l = set log file name (default is WordSendLog.txt in the current directory) filespec = SFM file specification to read If a JobOptions file is specified, and that file contains the input file specifications, then filespec(s) need not be specified on the command line. If filespec(s) or output files are specified on the command line, then the command line overrides those specifications in the job options file. You may use / instead of - to introduce switches. Do not use / or - as the first character of a file name. "); } // Read XML job options file. Note that this file is only read // from in the command line program, but may be // written to from the Windows UI version. It is reasonable to // set up the options the way you want them in the Windows UI // version of the program, then read them with this command line // version. We convert some command line arguments to entries // in this class for consistency in the handling of options // between the command line and Windows UI versions. SFConverter.jobIni = new XMLini(jobOptionsName); SFConverter.jobIni.WriteString("TemplateName", templateName); if (outName == "") { outName = SFConverter.jobIni.ReadString("outputFileName", "Output.xml"); } if (templateName != "") { SFConverter.jobIni.WriteString("templateName", templateName); } if (fileSpecs.Count < 1) { int numSfmFiles = SFConverter.jobIni.ReadInt("numSfmFiles", 0); for (i = 0; i < numSfmFiles; i++) { fileSpecs.Add( (object)SFConverter.jobIni.ReadString("sfmFile" + i.ToString(), "*.sfm")); } } if (fileSpecs.Count < 1) { Logit.WriteLine("Nothing to do. No input files specified."); } else { // We don't really have a need for application options in the // command line program, but if we did, they would go in the // following place: // SFConverter.appIni = new XMLini(Environment.GetEnvironmentVariable("APPDATA")+"\\SIL\\WordSend\\sf2word.xml"); // Here we instantiate the object that does most of the work. SFConverter.scripture = new Scriptures(); Logit.WriteLine("Job options: " + jobOptionsName); Logit.WriteLine("Output file: " + outName); // Read the input USFM files into internal data structures. for (i = 0; i < fileSpecs.Count; i++) { SFConverter.ProcessFilespec((string)fileSpecs[i]); } // Write out the WordML file. SFConverter.scripture.WriteToWordML(outName); } Logit.CloseFile(); }