private static void AddLocalizedHintContentsToDictionary(HtmlDom singlePageHtmlDom, Dictionary <string, string> dictionary, CollectionSettings collectionSettings)
{
var nameOfXMatterPack = singlePageHtmlDom.GetMetaValue("xMatter", collectionSettings.XMatterPackName);
string idPrefix = "";
var pageElement = singlePageHtmlDom.RawDom.SelectSingleNode("//div") as XmlElement;
if (XMatterHelper.IsFrontMatterPage(pageElement))
{
idPrefix = "FrontMatter." + nameOfXMatterPack + ".";
}
else if (XMatterHelper.IsBackMatterPage(pageElement))
{
idPrefix = "BackMatter." + nameOfXMatterPack + ".";
}
foreach (XmlElement element in singlePageHtmlDom.RawDom.SelectNodes("//*[@data-hint]"))
{
//why aren't we just doing: element.SetAttribute("data-hint", translation); instead of bothering to write out a dictionary?
//because (especially since we're currently just assuming it is in english), we would later save it with the translation, and then next time try to translate that, and poplute the
//list of strings that we tell people to translate
var key = element.GetAttribute("data-hint");
if (!dictionary.ContainsKey(key))
{
string translation;
var id = idPrefix + key;
if (key.Contains("{lang}"))
{
translation = LocalizationManager.GetDynamicString("Bloom", id, key, "Put {lang} in your translation, so it can be replaced by the language name.");
}
else
{
translation = LocalizationManager.GetDynamicString("Bloom", id, key);
}
dictionary.Add(key, translation);
}
}
}