2

如何在我的 wpf 项目中支持库尔德语?我为不同的文化创建资源文件(本地化)

French  ->  fr 
English ->  en
Arabic  ->  ar
.
.
.

Kurdish ->  ???

如果 Windows 不支持这种语言,我如何使用CultureAndRegionInfoBuilder类来添加这种文化?还有其他方法吗?

4

3 回答 3

4

ku-阿拉伯

所有支持的代码在这里

于 2013-07-16T12:42:06.113 回答
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");
}

格式化日期和时间

于 2020-01-23T10:51:39.033 回答
-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();
    }

}

阅读更多:是时候将库尔德文化添加到 VS .NET 全球化中了

于 2018-01-11T07:26:53.827 回答