You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Main/Mesnac.Basic/LocaleHelper.cs

165 lines
6.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mesnac.Basic
{
/// <summary>
/// 区域辅助类
/// </summary>
public class LocaleHelper
{
/// <summary>
/// 获取所有区域信息
/// </summary>
public static Dictionary<string, LocaleItem> AllLocales
{
get
{
Dictionary<string, LocaleItem> dic = new Dictionary<string, LocaleItem>() {
{ "da-DK", new LocaleItem() { Code = "da-DK", Country = "丹麦", Language = "丹麦语" } },
{ "DE-AT", new LocaleItem() { Code = "DE-AT", Country = "奥地利", Language = "德语" } },
{ "DE-CH", new LocaleItem() { Code = "DE-CH", Country = "瑞士", Language = "德语" } },
{ "DE-DE", new LocaleItem() { Code = "DE-DE", Country = "德国", Language = "德语" } },
{ "el-GR", new LocaleItem() { Code = "el-GR", Country = "希腊", Language = "希腊语" } },
{ "en-CA", new LocaleItem() { Code = "en-CA", Country = "加拿大", Language = "英语" } },
{ "en-GB", new LocaleItem() { Code = "en-GB", Country = "英国", Language = "英语" } },
{ "en-IE", new LocaleItem() { Code = "en-IE", Country = "爱尔兰", Language = "英语" } },
{ "en-US", new LocaleItem() { Code = "en-US", Country = "美国", Language = "英语" } },
{ "en-ES", new LocaleItem() { Code = "en-ES", Country = "西班牙", Language = "西班牙语" } },
{ "fi-FI", new LocaleItem() { Code = "fi-FI", Country = "芬兰", Language = "芬兰语" } },
{ "fr-BE", new LocaleItem() { Code = "fr-BE", Country = "比利时", Language = "法语" } },
{ "fr-CA", new LocaleItem() { Code = "fr-CA", Country = "加拿大", Language = "法语" } },
{ "fr-CH", new LocaleItem() { Code = "fr-CH", Country = "瑞士", Language = "法语" } },
{ "fr-FR", new LocaleItem() { Code = "fr-FR", Country = "法国", Language = "法语" } },
{ "it-CH", new LocaleItem() { Code = "it-CH", Country = "瑞士", Language = "意大利语" } },
{ "it-IT", new LocaleItem() { Code = "it-IT", Country = "意大利", Language = "意大利语" } },
{ "ja-JP", new LocaleItem() { Code = "ja-JP", Country = "日本", Language = "日语" } },
{ "ko-KR", new LocaleItem() { Code = "ko-KR", Country = "韩国", Language = "韩语" } },
{ "nl-BE", new LocaleItem() { Code = "nl-BE", Country = "比利时", Language = "荷兰语" } },
{ "nl-NL", new LocaleItem() { Code = "nl-NL", Country = "荷兰", Language = "荷兰语" } },
{ "no-NO", new LocaleItem() { Code = "no-NO", Country = "挪威", Language = "挪威语Nynorsk" } },
{ "no-NO-B", new LocaleItem() { Code = "no-NO-B", Country = "挪威", Language = "挪威语Bokmal" } },
{ "pt-PT", new LocaleItem() { Code = "pt-PT", Country = "葡萄牙", Language = "葡萄牙语" } },
{ "sv-SE", new LocaleItem() { Code = "sv-SE", Country = "瑞典", Language = "瑞典语" } },
{ "tr-TR", new LocaleItem() { Code = "rr-TR", Country = "土耳其", Language = "土耳其语" } },
{ "zh-CN", new LocaleItem() { Code = "zh-CN", Country = "中国", Language = "中文(简体)" } },
{ "zh-TW", new LocaleItem() { Code = "zh-TW", Country = "中国台湾", Language = "中文(繁体)" } },
};
return dic;
}
}
}
/// <summary>
/// 系统国际化资源数据类
/// </summary>
[Serializable]
public class SysMessage
{
private List<string> localeCodes = new List<string>() { "en-US", "zh-CN" };
private Dictionary<string, Dictionary<string, LocaleItem>> messages = new Dictionary<string, Dictionary<string, LocaleItem>>();
/// <summary>
/// 区域列表
/// </summary>
public List<string> LocaleCodes
{
get { return localeCodes; }
set { localeCodes = value; }
}
/// <summary>
/// 资源列表
/// </summary>
public Dictionary<string, Dictionary<string, LocaleItem>> Messages
{
get { return messages; }
set { messages = value; }
}
}
/// <summary>
/// 区域项
/// </summary>
[Serializable]
public class LocaleItem
{
private string code;
private string country;
private string language;
private string value;
/// <summary>
/// 区域代号
/// </summary>
public string Code
{
get { return code; }
set { code = value; }
}
/// <summary>
/// 国家
/// </summary>
public string Country
{
get { return country; }
set { country = value; }
}
/// <summary>
/// 语言
/// </summary>
public string Language
{
get { return language; }
set { language = value; }
}
/// <summary>
/// 区域值
/// </summary>
public string Value
{
get { return this.value; }
set { this.value = value; }
}
public override string ToString()
{
return String.Format("({0}) {1}", this.code , this.country + "-" + this.language);
}
}
/// <summary>
/// 国际化资源项
/// </summary>
//[Serializable]
//public class MessageItem
//{
// private string msgId;
// private Dictionary<string, LocaleItem> locales = new Dictionary<string, LocaleItem>();
// /// <summary>
// /// 资源Id
// /// </summary>
// public string MsgId
// {
// get { return msgId; }
// set { msgId = value; }
// }
// /// <summary>
// /// 区域集合信息
// /// </summary>
// public Dictionary<string, LocaleItem> Locales
// {
// get { return locales; }
// set { locales = value; }
// }
//}
}