|
using System;
using System.Xml;
using System.Collections;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Collections.Generic;
namespace Localization
{
public class Language
{
private string id = "";
private string name = "";
private string direction = Enumerations.LanguageDirection.ltr.ToString();
/// <summary>
/// Gets or sets the id of the language, as ar for Arabic or en for English
/// </summary>
public virtual string Id
{
get
{
return id;
}
set
{
id = value;
}
}
/// <summary>
/// Gets or sets the descriptive name for the language
/// </summary>
public virtual string Name
{
get
{
return name;
}
set
{
name = value;
}
}
/// <summary>
/// Get the culture info for the language
/// </summary>
public virtual System.Globalization.CultureInfo CultureInfo
{
get
{
if (id == "ar")
return new System.Globalization.CultureInfo("ar-lb");
else if (id == "en")
return new System.Globalization.CultureInfo("en-US");
else
return System.Globalization.CultureInfo.CurrentCulture;
}
}
/// <summary>
/// Gets or sets the layout direction settings for the language
/// </summary>
public virtual Enumerations.LanguageDirection Direction
{
get
{
return (Enumerations.LanguageDirection) Enum.Parse(typeof(Enumerations.LanguageDirection), direction, true);
}
set
{
direction = value.ToString();
}
}
public Language(string id, string name, Enumerations.LanguageDirection direction)
{
this.id = id;
this.name = name;
this.direction = direction.ToString();
}
private static List<Language> all = new List<Language>();
public static List<Language> All
{
get
{
lock (all)
{
if (all.Count == 0)
{
all = new List<Language>();
all.Add(new Language("ar", "����", Enumerations.LanguageDirection.rtl));
all.Add(new Language("en", "English", Enumerations.LanguageDirection.ltr));
}
}
return all;
}
}
//overriding the object's ToString method
public override string ToString()
{
return name;
}
// implicit conversion to a string
public static implicit operator string(Language language)
{
return language.Name;
}
public override bool Equals(object obj)
{
if (obj == null)
return false;
if (obj is Language)
{
Language language = (Language)obj;
return this.Id == language.Id;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return 0;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Been programming since 2001 interested in finance, security, workflows, SharePoint and algorithms. He is an MCSD, MCDBA, MCAD, MCSD, (again), MCTS, MCPD and MCT.
My Blog: www.alihamdar.com