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?
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.