Bloom.Book.BookData.PrettyPrintLanguage C# (CSharp) Method

PrettyPrintLanguage() public method

Give the string the user expects to see as the name of a specified language. This routine uses the user-specified name for the main project language. For the other two project languages, it explicitly uses the appropriate collection settings name for that language, though currently this gives the same result as the final default. This will find a fairly readable name for the languages Palaso knows about and fall back to the code itself if it can't find a name. Most names are not yet localized.
public PrettyPrintLanguage ( string code ) : string
code string
return string
        public string PrettyPrintLanguage(string code)
        {
            if (code == _collectionSettings.Language1Iso639Code && !string.IsNullOrWhiteSpace(_collectionSettings.Language1Name))
                return _collectionSettings.Language1Name;
            if (code == _collectionSettings.Language2Iso639Code)
                return _collectionSettings.GetLanguage2Name(_collectionSettings.Language2Iso639Code);
            if (code == _collectionSettings.Language3Iso639Code)
                return _collectionSettings.GetLanguage3Name(_collectionSettings.Language2Iso639Code);
            return _collectionSettings.GetLanguageName(code, _collectionSettings.Language2Iso639Code);
        }

Usage Example

Example #1
0
 public void PrettyPrintLanguage_DoesNotModifyUnknownCodes()
 {
     var htmlDom = new HtmlDom();
     var settingsettings = new CollectionSettings() { Language1Iso639Code = "pdc", Language1Name = "German, Kludged" };
     var data = new BookData(htmlDom, settingsettings, null);
     Assert.That(data.PrettyPrintLanguage("xyz"), Is.EqualTo("xyz"));
 }
All Usage Examples Of Bloom.Book.BookData::PrettyPrintLanguage