我如何在我的wpf项目中支持库尔德语? 我为不同的文化(本地化)
创建资源文件French -> fr
English -> en
Arabic -> ar
.
.
.
Kurdish -> ???
如果Windows不支持这种语言,我如何使用 CultureAndRegionInfoBuilder 类来添加这种文化? 还有其他方法吗?
答案 0 :(得分:3)
KU-阿拉伯
所有支持的代码here
答案 1 :(得分:0)
通过使用此类设置日期伊拉克格式
public static class DateSetting
{
public static string ToDateIraq(DateTime date) => date.ToString("dd/MM/yyyy");
public static string ToDateTimeIraq(DateTime date) => date.ToString("dd/MM/yyyy h:mm tt");
}
答案 2 :(得分:-1)
此代码显示如何使用 CultureAndRegionInfoBuilder 将库尔德语本地化添加到系统文化类型中。请注意,代码在 UserCustomCulture 商店中注册文化。此代码仅适用于Windows 7或更早版本。在Windows 10下工作不正常(我认为也是Windows 8)。在Windows 10中已经存在库尔德文化ku-Arab。
class Program
{
static void Main(string[] args)
{
BuildCulture();
}
public static void BuildCulture()
{
if(cultureExist())
CultureAndRegionInfoBuilder.Unregister("ku-KU");
Console.WriteLine("Create the CultureAndRegionInfoBuilder...");
var cib = new CultureAndRegionInfoBuilder("ku-KU", CultureAndRegionModifiers.None);
cib.CultureEnglishName = "Kurdish (Kurdistan)";
cib.RegionEnglishName = "Kurdistan";
cib.CultureNativeName = "ßæÑÏí";
var cia = new CultureInfo("ar-IQ");
cib.NumberFormat = cia.NumberFormat;
cib.GregorianDateTimeFormat = cia.DateTimeFormat;
cib.TextInfo = cia.TextInfo;
cib.CompareInfo = cia.CompareInfo;
cib.KeyboardLayoutId = cia.KeyboardLayoutId;
cib.RegionNativeName = "ßæÑÏÓÊÇä";
cib.ThreeLetterISOLanguageName = "kur";
cib.ThreeLetterISORegionName = "kur";
cib.TwoLetterISORegionName = "ku";
cib.ThreeLetterWindowsRegionName = "kur";
cib.ISOCurrencySymbol = "USD";
cib.CurrencyNativeName = "Dinary Kurdi";
cib.CurrencyEnglishName = "Kurdish Dinar";
var cinull = new CultureInfo("");
cib.Parent = cinull;
cib.ThreeLetterWindowsLanguageName = "kur";
cib.TwoLetterISOLanguageName = "ku";
cib.IetfLanguageTag = "kurdisk";
cib.Register();
cib.Save(@"C:\temp\kurdish.xml"); //Save created culture to XML document
Console.WriteLine("Create and explore the custom culture...");
var ci = new CultureInfo("ku-KU");
Console.WriteLine("Name: . . . . . . . . . . . . . {0}", ci.Name);
Console.WriteLine("EnglishName:. . . . . . . . . . {0}", ci.EnglishName);
Console.WriteLine("NativeName: . . . . . . . . . . {0}", ci.NativeName);
Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", ci.TwoLetterISOLanguageName);
Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", ci.ThreeLetterISOLanguageName);
Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", ci.ThreeLetterWindowsLanguageName);
Console.Read();
}
//Register culture from XML file
private void cmdCreateCultureFromXML()
{
if(cultureExist())
CultureAndRegionInfoBuilder.Unregister("ku-KU");
CultureAndRegionInfoBuilder cib = CultureAndRegionInfoBuilder.CreateFromLdml(@"C:\temp\kurdish.xml");
cib.Register();
}
private static bool cultureExist()
{
var cultures = CultureInfo.GetCultures(CultureTypes.UserCustomCulture);
return cultures.Where(s => s.Name == "ku-KU").Any();
}
}