Friendly name from resource file

Friendly name from resource file

Old forum URL: forums.lhotka.net/forums/t/12103.aspx


flying_monkey posted on Friday, August 02, 2013

Hi,

I have been using the friendly name in the property info to provide proper business rule messages. My problem now is that I need to have my application run in more the one locale. I saw this post http://forums.lhotka.net/forums/t/6888.aspx where JonnyBee says to put the friendly name into a resource file and then use that to easily translate the friendly names.

My problem is I tried this, I have two resource files in my application. Resources.resx and Resources.fr-CA.resx. The friendly name seems to successfully pull from Resources.resx at application start but when I switch languages the friendly name doesn't pull from the correct file and just shows from the default Resources.resx.

Does anyone have any ideas of what I'm missing?

Thanks for the help.

JonnyBee replied on Saturday, August 03, 2013

Which type of application (web, SL, WPF, WinForms) do you have?

You would typically not change language after startup in a rich client.

My first solution was to load from resource when application start up (the users Culture).

For a web application is more complex - as this requires your own IPropertyInfo that reads from resource file on each read of FriendlyName.

RegisterProperty is only called once per property (as it is static) so 

  1. You may create your own PropertyInfoFactory to set the friendly name from resource file (but only one selected/active language in a "rich" client)
  2. You may subclass PropertyInfo and change FriendlyName to read from resource file. Then your custom PropertyInfoFactory must create the new subclassed PropertyInfo. This will work for a web application / application server as well.

I only needed 1 for "rich" client in edge application. 

Copyright (c) Marimer LLC