Bloom.Book.TranslationGroupManager.SetInitialMultilingualSetting C# (CSharp) Method

SetInitialMultilingualSetting() public static method

This is used when a book is first created from a source; without it, if the shell maker left the book as trilingual when working on it, then every time someone created a new book based on it, it too would be trilingual.
public static SetInitialMultilingualSetting ( BookData bookData, int oneTwoOrThreeContentLanguages, CollectionSettings collectionSettings ) : void
bookData BookData
oneTwoOrThreeContentLanguages int
collectionSettings Bloom.Collection.CollectionSettings
return void
        public static void SetInitialMultilingualSetting(BookData bookData, int oneTwoOrThreeContentLanguages,
			CollectionSettings collectionSettings)
        {
            //var multilingualClass =  new string[]{"bloom-monolingual", "bloom-bilingual","bloom-trilingual"}[oneTwoOrThreeContentLanguages-1];

            if (oneTwoOrThreeContentLanguages < 3)
                bookData.RemoveAllForms("contentLanguage3");
            if (oneTwoOrThreeContentLanguages < 2)
                bookData.RemoveAllForms("contentLanguage2");

            bookData.Set("contentLanguage1", collectionSettings.Language1Iso639Code, false);
            bookData.Set("contentLanguage1Rtl", collectionSettings.IsLanguage1Rtl.ToString(), false);
            if (oneTwoOrThreeContentLanguages > 1)
            {
                bookData.Set("contentLanguage2", collectionSettings.Language2Iso639Code, false);
                bookData.Set("contentLanguage2Rtl", collectionSettings.IsLanguage2Rtl.ToString(), false);
            }
            if (oneTwoOrThreeContentLanguages > 2 && !string.IsNullOrEmpty(collectionSettings.Language3Iso639Code))
            {
                bookData.Set("contentLanguage3", collectionSettings.Language3Iso639Code, false);
                bookData.Set("contentLanguage3Rtl", collectionSettings.IsLanguage3Rtl.ToString(), false);
            }
        }

Usage Example

Example #1
0
        private string SetupNewDocumentContents(string sourceFolderPath, string initialPath)
        {
            var storage  = _bookStorageFactory(initialPath);
            var bookData = new BookData(storage.Dom, _collectionSettings, null);

            UpdateEditabilityMetadata(storage);            //Path.GetFileName(initialPath).ToLower().Contains("template"));

            //NB: for a new book based on a page template, I think this should remove *everything*, because the rest is in the xmatter
            //	for shells, we'll still have pages.
            //Remove from the new book any div-pages labelled as "extraPage"
            foreach (XmlElement initialPageDiv in storage.Dom.SafeSelectNodes("/html/body/div[contains(@data-page,'extra')]"))
            {
                initialPageDiv.ParentNode.RemoveChild(initialPageDiv);
            }

            XMatterHelper.RemoveExistingXMatter(storage.Dom);

            bookData.RemoveAllForms("ISBN");            //ISBN number of the original doesn't apply to derivatives

            var sizeAndOrientation = Layout.FromDom(storage.Dom, Layout.A5Portrait);

            //Note that we do this *before* injecting frontmatter, which is more likely to have a good reason for having English
            //Useful for things like Primers. Note that Lorem Ipsum and prefixing all text with "_" also work.
//			if ("true"==GetMetaValue(storage.Dom.RawDom, "removeTranslationsWhenMakingNewBook", "false"))
//			{
//				ClearAwayAllTranslations(storage.Dom.RawDom);
//			}

            InjectXMatter(initialPath, storage, sizeAndOrientation);

            SetLineageAndId(storage);

            SetBookTitle(storage, bookData);



            //Few sources will have this set at all. A template picture dictionary is one place where we might expect it to call for, say, bilingual
            int multilingualLevel = int.Parse(GetMetaValue(storage.Dom.RawDom, "defaultMultilingualLevel", "1"));

            TranslationGroupManager.SetInitialMultilingualSetting(bookData, multilingualLevel, _collectionSettings);

            var sourceDom = XmlHtmlConverter.GetXmlDomFromHtmlFile(sourceFolderPath.CombineForPath(Path.GetFileName(GetPathToHtmlFile(sourceFolderPath))), false);

            //If this is a shell book, make elements to hold the vernacular
            foreach (XmlElement div in storage.Dom.RawDom.SafeSelectNodes("//div[contains(@class,'bloom-page')]"))
            {
                XmlElement sourceDiv = sourceDom.SelectSingleNode("//div[@id='" + div.GetAttribute("id") + "']") as XmlElement;
                SetupIdAndLineage(sourceDiv, div);
                SetupPage(div, _collectionSettings, null, null);
            }

            ClearAwayDraftText(storage.Dom.RawDom);

            storage.Save();

            //REVIEW this actually undoes the setting of the intial files name:
            //      storage.UpdateBookFileAndFolderName(_librarySettings);
            return(storage.FolderPath);
        }
All Usage Examples Of Bloom.Book.TranslationGroupManager::SetInitialMultilingualSetting