# HG changeset patch # User IBBoard # Date 1270578014 0 # Node ID cec6c4c0892d75fa6505b91d196832dead09acfb # Parent 40c09e57d2134fa358a120332c57c67037d17491 Fixes #34: Get name for translation * Add code for translation name fetching (using native name) diff -r 40c09e57d213 -r cec6c4c0892d Lang/AbstractTranslationSet.cs --- a/Lang/AbstractTranslationSet.cs Tue Apr 06 18:08:43 2010 +0000 +++ b/Lang/AbstractTranslationSet.cs Tue Apr 06 18:20:14 2010 +0000 @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Globalization; namespace IBBoard.Lang { @@ -14,6 +15,7 @@ public class AbstractTranslationSet { private string langCode; + private string langName; protected Dictionary translations; public AbstractTranslationSet(string languageCode) @@ -46,6 +48,32 @@ { return DictionaryUtils.GetValue(translations, key); } - } + } + + public string LanguageName + { + get + { + if (langName == null) + { + LoadLangName(); + } + + return langName; + } + } + + private void LoadLangName() + { + try + { + CultureInfo culture = CultureInfo.GetCultureInfo(langCode); + langName = culture.NativeName; + } + catch(ArgumentException) + { + langName = "Unknown ("+langCode+")"; + } + } } }