/// <summary> /// 应用字符串本地化。 /// </summary> public void Apply() { var manager = StringLocalizerFactory.CreateManager(); if (manager == null || string.IsNullOrEmpty(Name)) { return; } var localizer = manager.GetLocalizer(Name); foreach (var kvp in _keys) { if (kvp.Key is Control control) { control.Text = localizer[kvp.Value]; } else if (kvp.Key is TreeListColumn column) { column.Text = localizer[kvp.Value]; } } }
public void TestNoExistsKey() { var localizer = StringLocalizerFactory.CreateManager().GetLocalizer("Localization.Test", typeof(DefaultStringLocalizerTest).Assembly); Console.WriteLine(localizer["String6"]); }
public void TestNoExists() { var localizer = StringLocalizerFactory.CreateManager().GetLocalizer("Localization.Test", CultureInfo.GetCultureInfo("ru"), typeof(DefaultStringLocalizerTest).Assembly); Console.WriteLine(localizer["String3", "c:\\1.txt"]); }
public void TestFormat() { var localizer = StringLocalizerFactory.CreateManager().GetLocalizer("Localization.Test", typeof(DefaultStringLocalizerTest).Assembly); Console.WriteLine(localizer["String3", "c:\\1.txt"]); }
public void TestWithCulture() { var localizer = StringLocalizerFactory.CreateManager().GetLocalizer("Localization.Test", CultureInfo.GetCultureInfo("en"), typeof(DefaultStringLocalizerTest).Assembly); Console.WriteLine(localizer["String1"]); }