views:

38

answers:

1

Hello,

my web application uses a menu for the user navigation, and I need to store the menu in the database. among other properties, each menu item has a text title. But I do not want to store title strings in the database. Instead I want to use resource files to plug in the right language. I am looking for an advice on how to link the database table and the resources together. I mean, what would a store instead of the title in the database? the corresponding resource id? But this seems wrong. Any advice?

A: 

You could use the same type of unique identifier in a database that you would in a bound localisation value (if it were in a WPF or Silverlight binding expression).

That is, your lookup values would be:

  • Something unique (machine requirement)
  • Something still readable (human readability requirement)

Your specific menu lookup values could be something as simple as "menu.home" for the "Home" menu string, "menu.view" for the "View" menu string etc. That type of naming keeps them both organised and meaningful, so take time to choose good names.

Hope this helps.

Enough already
do you mean that in my resources file i would have<data name="menu_home"><value>Home</value></data>and the database would have the string 'menu_home' stored in the caption field?if so, i agree. i think this is the only way to do it. wanted to confirm that others are doing the same. thanks.
akonsu