.NET has many built in structures for setting up your web application to support multiple languages. Most of which reside in the System.Globalization namespace. Within the System.Globalization namespace you get access to the CultureInfo class. This class defines how datatypes such as Dates, Currency and other culture related objects are displayed.
For example if the CultureInfo object is set to “mx-es” (spanish) the date would be displayed dd/mm/yyyy instead of mm/dd/yyyy. You can manage all the output settings by setting their respective properties in the CultureInfo class.
Now that we have a very basic idea of what the built in .NET tools provide us in terms of *displaying *internationalized data lets take a look at the solutions we have for *storing *globalized data.
So lets say we have a database table called Product with a field called “Description” we want to internationalize:
|1||Vista||If you own or run a small business, you’ll want Windows Vista Business.||6/22/2009 3:57:07 PM|
Another option would be to build a look up table that stores translated values and replaces our description with a reference. This method would allow for efficiently searching and indexing but would increase the complexity of our database structure.
In our situation we decided to store every language into an XML document. The benefits of doing it this way is it allows us to add infinitely many translated versions of the product name without affecting are database structure. The draw back of using this method is the inability to efficiently search through the database on the internationalized column(s).
Let’s say we wanted to store English/French/Spanish/German translations of our product description we could do so by generating an XML file that looks similar to this.[sourcecode lang="xml"]
Each value element represents a language and has an attribute called language which is set to a culture name. A list of culture names can be found here MSDN Culture Names
Updated Table Data:
|1||Vista||6/22/2009 3:57:07 PM|
That is it for part 1 . In part 2 I will discuss building a class/datatype that will get,set and build the above XML document for storing our translated values.