Introduction

In today's world, localization has become a must requirement in applications that we develop. We can easily achieve this goal by using resource files for static resources
such as exception messages, label texts, etc. However, using localized data fetched from a data source will be a problem. Since the data is dynamic, this problem cannot
be solved with resource files.

Using the code

Most developers solve this problem by using a design like below.

If we look at the design, we can see that we are creating a new object for each property that contains multi-language data. All these objects cause the developer
to write more code, and also will make the application code less manageable. If the developer is using an ORM tool, s/he will end up creating lots of mapping.

Now let's think from another perspective and try to implement a design like below.

As you can see, this design is much simpler to understand and has high reusability. You can use MultilanguageProperty to store multi-language data as a property of an object.

Now let's see how we can write this code from design.

First of all, let's code the Language class that we will use in MultilanguageProperty.

As you can see, we define the languages we want to use in an enum. And we implement a method that is responsible for returning the default language.
This method can return the default language per session or per user based on our implementation.

First of all, to use our object with any type, we are making the object generic. And to allow users iterate through the child items in this object, we implement
the IEnumerable interface as above.

Declaring a property whose type is IDictionary is the main idea of this implementation. This
Dictionary
will store the data based on the language value. As you can see, IDictinary is a generic type of ApplicationLanguage enum as key and T generic type as value.
And in the constructor of our code, we create an instance of this Dictionary.

Now let's implement some code to access the data stored in the Values property.