How to Localize Enums in C#

Published: 24 August 2020
on channel: Brian Lagunas
9,338
316

In this video, I answer the question "How to Localize Enums in C#".

There are actually two problems we have to solve when we want to localize enums. First, we have to find a way to provide a long text description to represent an enum value. Once that is solves, then we have to figure ut how to localize the long text description for the enum.

In this video, we will use two custom classes to solve both these problems. The first problem will be solved by using an enum custom type converter. We will use this TypeConverter to read a System.ComponentModel.Description attribute that can be added to each enum value to represent the long text desriptions.

Then we will create a custom enum description attribute that we can use instead of the System.ComponentModel.Description attribute. We will then make use of the ResourceManager to localize enums based on the resource files defined in our application.

Hopefully, by the end of this video you'll be able to localize enums in your WPF application.

Be sure to watch my new Pluralsight course "Introduction to Prism for WPF":
https://pluralsight.pxf.io/bE3rB

Sponsor Me:
https://github.com/sponsors/brianlagunas

Follow Me:
Twitter:   / brianlagunas  
Twitch:   / brianlagunas  
Blog: http://brianlagunas.com
GitHub: https://github.com/brianlagunas


Watch video How to Localize Enums in C# online without registration, duration hours minute second in high quality. This video was added by user Brian Lagunas 24 August 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 9,33 once and liked it 31 people.