views:

131

answers:

2

Multi language content application in ASP.Net can usually be overcome by using resource files. However when it comes to dynamic content that need to be multi-language. what would be the ideal system design?

Example like having a questionnaire application, each question text and answer options need to be translated.

Is storing the specific language text/content using a resource key idea good? by using the question text or the main english version of the text as a key a good idea?

Because i am trying to reduce database calls whenever my system programmatically creates the questions on the page.

+2  A: 

Resource files should just hold the keys/reference and nothing language specific should be put in there.

All your specific translations should reside in the database. So, whenever your System dynamically creates questions there would be ONE and ONLY ONE DB call...using the Locale identifier and the appropriate language version of the question would be loaded.

Shankar Ramachandran
A: 

This depends quite a lot on your survey system design, you have a few options.

For example, if you are storing each individual survey in an xml file with all the questions/answers encoded there, you may be able to get away with generating a new xml file per language. The additional files would contain only translated questions/answers.

So, you may have the survey IsASPAwesome.xml, and would generate IsASPAweseome.enUS.xml, IsASPAwesome.frFR.xml and so forth. Another option if you want to use a single file is to have multiple text values for each language you want and then select the appropriate for the language. Something like this (excuse the poor xml and worse french)

<survey>
    <question id=1>
         <questionText lang="enUS">how great is this?</questionText>
         <questionText lang="frFR">Comment est ce grand?</questionText>
         <answer value="GOOD" lang="enUS" sortOrder="1">Great!</answer>
         <answer value="BAD" lang="enUS" sortOrder="2">Not so great</answer>
         <answer value="GOOD" lang="frFR" sortOrder="1">Grand!</answer>
         <answer value="BAD" lang="frFR" sortOrder="2">Merde!</answer>
    </question>
</survey>

If you were storing this in a DB, you should be able to get away with the same amount of DB calls, as you would just add an additional condition to your select query (ie SELECT answerText,Value FROM questionAnswers WHERE questionId=2 AND lang="frFR")

Using a separate survey per language may make processing the results a little harder, but it does make coding multi-lingual support a fiar bit easier. furthermore, it makes caching easier too (which is a good idea if you want to limit your DB calls, as survey's don't change that often).

I went down the "multiple XML file" approach for a previous project and it was sufficient, and also allowed translators to work simlutaneously and, in one case, suggest more appropriate ordering of questions for cultural reasons.

Hope this helps!

Sam Pride
The xml solution looks good though - as for now i am implementing a DB side to this multi language problem. I can't have dynamic columns in the DB cos my client will be adding new languages and i dun want to alter the structure once the project is launched.
Ethan Chan