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

PrepareDataBookTranslationGroups() public static method

Normally, the connection between bloom-translationGroups and the dataDiv is that each bloom-editable child (which has an @lang) pulls the corresponding string from the dataDiv. This happens in BookData. That works except in the case of xmatter which a) start empty and b) only normally get filled with .bloom-editable's for the current languages. Then, when bloom would normally show a source bubble listing the string in other languages, well there's nothing to show (the bubble can't pull from dataDiv). So our solution here is to pre-pack the translationGroup with bloom-editable's for each of the languages in the data-div. The original (an possibly only) instance of this is with book titles. See bl-1210.
public static PrepareDataBookTranslationGroups ( XmlNode pageOrDocumentNode, IEnumerable languageCodes ) : void
pageOrDocumentNode System.Xml.XmlNode
languageCodes IEnumerable
return void
        public static void PrepareDataBookTranslationGroups(XmlNode pageOrDocumentNode, IEnumerable<string> languageCodes)
        {
            //At first, I set out to select all translationGroups that have child .bloomEditables that have data-book attributes
            //however this has implications on other fields, noticeably the acknowledgments. So in order to get this fixed
            //and not open another can of worms, I've reduce the scope of this
            //fix to just the bookTitle, so I'm going with findOnlyBookTitleFields for now
            var findAllDataBookFields = "descendant-or-self::*[contains(@class,'bloom-translationGroup') and descendant::div[@data-book and contains(@class,'bloom-editable')]]";
            var findOnlyBookTitleFields = "descendant-or-self::*[contains(@class,'bloom-translationGroup') and descendant::div[@data-book='bookTitle' and contains(@class,'bloom-editable')]]";
            foreach (XmlElement groupElement in
                    pageOrDocumentNode.SafeSelectNodes(findOnlyBookTitleFields))
            {
                foreach (var lang in languageCodes)
                {
                    MakeElementWithLanguageForOneGroup(groupElement, lang);
                }
            }
        }