Skip to content

Instantly share code, notes, and snippets.

@kenzauros
Last active September 24, 2018 12:07
Show Gist options
  • Save kenzauros/0d61bb42fb3410a238f896234a8cad19 to your computer and use it in GitHub Desktop.
Save kenzauros/0d61bb42fb3410a238f896234a8cad19 to your computer and use it in GitHub Desktop.
Extended WPF Toolkit PropertyGrid ローカライズ (国際化/多言語対応)
using System.ComponentModel;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
namespace YourApplication
{
internal class LocalizedCategoryAttribute : CategoryAttribute
{
public LocalizedCategoryAttribute(string resourceKey)
: base(LocalizedResources.GetString(resourceKey)) { }
}
internal class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
public LocalizedDisplayNameAttribute(string resourceKey)
: base(LocalizedResources.GetString(resourceKey)) { }
}
internal class LocalizedDescriptionAttribute : DescriptionAttribute
{
public LocalizedDescriptionAttribute(string resourceKey)
: base(LocalizedResources.GetString(resourceKey)) { }
}
internal class LocalizedCategoryOrderAttribute : CategoryOrderAttribute
{
public LocalizedCategoryOrderAttribute(string resourceKey, int order)
: base(LocalizedResources.GetString(resourceKey), order) { }
}
}
using System.Resources;
namespace YourApplication
{
internal static class LocalizedResources
{
readonly static ResourceManager _ResourceManager = new ResourceManager(typeof(Resources));
public static string GetString(string resourceKey)
{
return _ResourceManager.GetString(resourceKey) ?? resourceKey;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment