0

I have a table with two columns ID | Material and I need to add an English translation to the material column. If I didn't have the unique id I guess I could use this answer: https://stackoverflow.com/a/219871/536610

But it won't work with a unique id (as far as I know). Is the best solution to add a new column called EngMaterial and add the English translation there, or is it possible to solve this in a better way with localization in .NET?

Community
  • 1
  • 1
Niklas
  • 13,005
  • 23
  • 79
  • 119
  • You can create resource files in the App_GlobalResources folder in your solution and just save the keys for the localized strings in your table. – QQping Mar 15 '12 at 15:35

1 Answers1

1

A completely in-database solution is to add another table. Adding a column per-language is a (poor) temporary solution at best - it doesn't scale well, and would require dynamic sql to choose the column (which may cause errors if the language code is available, but there's no appropriately named column).

Keep your existing table as-is. It makes a great primary-key table for referential integrity, and also allows for easy storage of defaults, if the appropriate language can't be found. Then add another table like this:

Material_Localizations
========================
materialId  -- fk reference to Material.id
languageId  -- fk reference to Language.id
regionId  -- optional - used to differentiate where the particular language is 
          -- being spoken: some places use different spellings or whole words
materialDescription  -- varchar, localized text

primary (unique) key is <materialId, languageId, regionId>
Clockwork-Muse
  • 12,806
  • 6
  • 31
  • 45