changeset 72:cec6c4c0892d

Fixes #34: Get name for translation * Add code for translation name fetching (using native name)
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Apr 2010 18:20:14 +0000
parents 40c09e57d213
children 091bfa54d6c7
files Lang/AbstractTranslationSet.cs
diffstat 1 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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<string, string> 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+")";
+			}
+		}
 	}
 }