Bloom.Book.RuntimeInformationInjector.AddTranslationToDictionaryUsingEnglishAsKey C# (CSharp) Method

AddTranslationToDictionaryUsingEnglishAsKey() private static method

private static AddTranslationToDictionaryUsingEnglishAsKey ( string>.Dictionary dictionary, string key, string defaultText ) : void
dictionary string>.Dictionary
key string
defaultText string
return void
        private static void AddTranslationToDictionaryUsingEnglishAsKey(Dictionary<string, string> dictionary, string key, string defaultText)
        {
            var translation = _collectDynamicStrings
                ? LocalizationManager.GetDynamicString("Bloom", key, defaultText)
                : LocalizationManager.GetString(key, defaultText);

            //We have to match on some key. Ideally, we'd match on something "key-ish", like BookEditor.FrontMatter.BookTitlePrompt
            //But that would require changes to all the templates to have that key somehow, in adition to or in place of the current English
            //So for now, we're just keeping the real key on the c#/tmx side of things, and letting the javascript work by matching our defaultText to the English text in the html
            var keyUsedInTheJavascriptDictionary = defaultText;
            if (!dictionary.ContainsKey(keyUsedInTheJavascriptDictionary))
            {
                dictionary.Add(keyUsedInTheJavascriptDictionary, WebUtility.HtmlEncode(translation));
            }
        }