implement multi language support

Posts   
 
    
ChBaeumer
User
Posts: 175
Joined: 23-Oct-2003
# Posted on: 12-Mar-2010 15:47:17   

I have a question how to handle multi language in an efficient way.

Today I have following


table Element (
    ElementPK
)

table ElementAttribute
(
    ElementAttributePK,
    ElementPK,
    Locale,
    Value
)

  • There exists a table which holds all available languages.
  • There exists a default language which should be used when an attribute for a locale is not defined.
  • Languages can be added and removed during runtime. So, in the code I load all ElementAttribute of the element and first search for the specified locale and if it is not found I search for the default locale.

This makes it hard to bind the element entity to GUI components since I have to write public properties the retrieve the correct values. Another thing I don't like is that the element needs access to the language table. The element entity should be unaware of this.

Is this the way it has to be done? How do you handle this?

Christoph

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 12-Mar-2010 20:14:15   

Have you looked into .NET globalization? You can set the current thread's UICulture which would do this.

-Seth

ChBaeumer
User
Posts: 175
Joined: 23-Oct-2003
# Posted on: 13-Mar-2010 10:51:04   

No thats not the same.

You have to differenciate between the language used for the GUI and the language used in a model.

In my case I have a modeller for business processes. The business process should be displayed in different languages i.e. the content of the application. The user models in a default language and has the capability to translate the content to different languages.

The whole model can than be exported to html and then the client can choose the display language of the model, i.e the business process with its content.

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 14-Mar-2010 00:29:40   

I don't think it's clear what you are asking. Is your question about database efficiency? Database design?

When I have done this in the past with a similar model, I use the database to store languages, keys, default text, and translated text (per language, per key) and pull the information into a "translation dictionary" for the user (in a WPF/Winforms environment) or globally, one per language (in a web environment).

I think it's possble to do it with entities, but translations really lend themselves to in-memory key/value pair dictionaries, which are a far more efficient way to look up the information (this is assuming you don't have millions of translation which may not work as it would take up a lot of memory). So load the translations into a dictionary(s) once at startup (and maybe refresh periodically or manually when there are translation changes), and then look them up as you need them.

I have no idea if this fits your scenario or not, but from my experience it is a very efficient way to do it.

ChBaeumer
User
Posts: 175
Joined: 23-Oct-2003
# Posted on: 28-Apr-2010 16:18:56   

Thank you for you responses.

I think I found a solution which suits my business case.