views:

41

answers:

2

Hi,

Let's say I have 2 entities in my data layer (Country and Language) that have to be localized depending the user language.

The normal option would be to just create a DB table with the translations and add a parameter to every query with the user language. Ok, no problem, but i'm looking for alternatives here.

Would be a better alternative to store the translations in RESX files and just add a property to my objects to get the translated name? Where should I put this resx files? in my Data project? A separete project? Any other alternative?

A: 

It depends on where you load your data from. If you load it from a database, use a database table. If your Countries and Languages are static data, you might opt for a utilityclass with several localized resx files.

Webleeuw
+1  A: 

If the texts are constants (not changing while working with the application), they could actually belong to the resx files. A advantage is that it automatically falls back to the closest known language (for instance, if you don't support en-uk, it falls back to en-us, English people will hate me for this example :-)

Put it to the highest layer that needs the texts. For instance, if you only need in the UI, put the texts to the UI layer. Business logic can easily (or even better) live with keys. If you need it in your business layer, for instance for export features or log files, you need to put it there.

Stefan Steinegger
Nice! very good idea to just move it to the highest layer. Yes, i can live with keys in everthing under the UI.I was thinking too much for something so simple!
Drevak