I have a multi-language web application. I am converting all the controls i.e. labels, drop down, text, and messages using resource file.
Problem:
For example, registration page has drop down of Prefix- Mr, Mrs,Miss etc. This prefix data comes from a table and is configurable i.e We are having a configuration web page for the same.
There are many other configurable things and corresponding pages.
My question is how to convert this data into other language and how to save the same as it cannot be done with resource file.
Anyone having practical ideas can guide me.
If it's user configurable, then it's not practical to use resource files, for users can configure whatever they need.
So, if I understood correctly, I think the only practical solution is having translations in a table for each value users enter.
Since users can enter values in any language it can get tricky.
I would choose a default required language, say english, so whenever users manage the values (Title or prefix in your sample), they have to manage them in pairs, i.e. their language and english.
So, if the locale is french, when they check the index of titles, they see two columns, one for french and one for english.
If it's the first time the french user enters the view, then there are no french values, so the user has to add the french translation for the english values al ready registered.
If the user adds a new [french] value, then she/he has to enter the english translation too.
It looks a litle cumbersome and may be not very practical, but it's an option!
Best,
PD: Hey, please share the solution when you get to it!
Microsoft .NET provides support for working with culture specific information using the CultureInfo class in the System.Globalization namespace. Culture information can be set both at the page level as well as at the application level.
<%@ Page language="C#" Culture="fr-FR"%>
To set the Culture information at the application level, use the following in the Globalization section of the web.config file.
<configuration>
<system.web>
<globalization
culture="en-GB"
/>
</system.web>
</configuration>
try this,
http://aspalliance.com/articleViewer.aspx?aId=957&pId=-1
For example, registration page has drop down of Prefix- Mr, Mrs,Miss etc. This prefix data comes from a table and is configurable i.e We are having a configuration web page for the same.
Since the values of the drop down are in the database, I think the translation should be in the database too.
The easy way is way is to have a field for each language in your titles table :
--------------------------
| Id | TitleEn | TitleFr |
--------------------------
| 1 | Mr | M |
| 2 | Mrs | Mme |
| 3 | Miss | Mlle |
--------------------------
However this will not scale well if you have more language or if you want to add languages in the future.
The way I would do it would be to add a localized_string table like this :
--------------------------
| Id | Language | String |
--------------------------
| 7 | FR | M |
| 8 | FR | Mme |
| 9 | FR | Mlle |
| 7 | EN | Mr |
| 8 | EN | Mrs |
| 9 | EN | Miss |
--------------------------
In your titles table and in any other tables where you need a localized_string you store the Id of the string :
----------------------------
| Id | localized_string_id |
----------------------------
| 1 | 7 |
| 2 | 8 |
| 3 | 9 |
----------------------------
This way you can query the localized string in any language and you can add as many language as you want without modifying your database schema.