Bloom.Api.I18NHandler.GetTranslationDefaultMayNotBeEnglish C# (CSharp) Method

GetTranslationDefaultMayNotBeEnglish() public static method

We want the translation of the specified key in the current UI language. The normal LocalizationManager call expects to be passed an English default, which it will return if the language is English or if it has no translation for the string in the target language. The current default passed as an argument typically comes from the content of the element whose data-i18n attribute is the key in this method. However, this string may come from an earlier loclization and therefore NOT be English. If we pass it as the english default, we will get it back unchanged if the UI language has changed (back) to English. We will also get something other than English as a default for any langauge in which we don't have the localization.
public static GetTranslationDefaultMayNotBeEnglish ( string key, string defaultCurrent ) : string
key string
defaultCurrent string
return string
        public static string GetTranslationDefaultMayNotBeEnglish(string key, string defaultCurrent)
        {
            string translation;
            if (LocalizationManager.GetIsStringAvailableForLangId(key, LocalizationManager.UILanguageId))
            {
                // If we HAVE the string in the desired localization, we don't need
                // a default and can just return the localized string; not passing a default ensures that
                // even in English we get the true English string for this ID from the TMX.
                translation = LocalizationManager.GetDynamicString("Bloom", key, null);
            }
            else
            {
                // Don't report missing strings if they are numbers
                // Enhance: We might get the Javascript to do locale specific numbers someday
                // The C# side doesn't currently have the smarts to do DigitSubstitution
                // See Remark at https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.digitsubstitution(v=vs.110).aspx
                if (IsInteger(key))
                {
                    translation = key;
                }
                else
                {
                    // We don't have the string in the desired localization, so will return the English.
                    translation = LocalizationManager.GetDynamicStringOrEnglish("Bloom", key, null, null, "en");
                    // If somehow we don't have even an English version of it, keep whatever was in the element
                    // to begin with.
                    if (string.IsNullOrWhiteSpace(translation))
                    {
                        translation = defaultCurrent;
                        ReportL10NMissingString(key, translation);
                    }
                }
            }
            return translation;
        }