internationalization - How to apply i18n to values that are stored in a database? -


i'm building website using visual studio 2012 mvc4 , entity framework 5. thing is, have apply i18n of values stored in database. e.g., need have dropdown showing employment areas (engineering, health, finance, etc.), both in spanish , english.

i thinking of 2 different approaches, none of them sounds 100% ok me:

  1. add columns in "area" table reflect area name in different languages (e.g.: areaid, englishname, spanishname). doesn't sound design-wise since i'm lucky have 2 languages, if had 100 languages support?

  2. don't save areas in database, add them in views, using i18n keys , reading values resource files. adding logic view (i'd have use iteration there), doesn't seem either.

is there else i'm missing, better way it?

thanks!!

first of all, think keeping i18n logic separate database entities better approach in terms of flexibility , maintenance.

so in order keep i18n separate database either use enumerations (it's has disadvantages well) or use i18n variable each employment area. instance in message.properties.en have:

employmentarea.engineering = engineering employmentarea.health = health employmentarea.finance = finance 

for reasons if need use database, have separate language table , solve problem follows:

table area

id code     -- ----     1  eng      2  heath    3  finance  

table area_language

id area_id lang_code name -- ------- --------- ---- 1  1       en        engineering 2  2       en        health 3  3       en        finance 4  1       es        ingenierĂ­a 5  2       es        salud 6  3       es        financiar 

so in way filter lang_code. using iso standard lang_code filter you.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -