Allow Naked Objects attributes to read values from resx file

Oct 31, 2011 at 11:52 AM

I have looked at the internationalisation and localisation notes in the developer docs and it states that:

"Naked Objects has full support for internationalisation (sometimes referred to as 'i18n') and localisation ('l10n') - allowing an application to be presented in different languages and/or cultures for different users without having to alter the domain code."

However, I have not yet found a way to use values from resource files (.resx) in all of the attributes I need to decorate my model with.  I.e. DescribedAs (NakedObjects) or Description (Microsoft)

Some attributes do provide corresponding methods which will allow me to provide a value from a resx file.  I.e. Title property and Title method.  However, not all attributes have corresponding methods to allow me to do this.

Have I missed something crucial in the docs, and Naked Objects does, as it states, fully support internationalisation and localisation, including values used for attributes?

If so, I am sorry, and please can someone point me in the right direction.

If not, then I would like to recommend that either/or:

1. All attributes which can take values needing internationalisation and localisation should have a new overloaded constructor that can take a resource type and a resource name.

2. All attributes which can take values needing internationalisation and localisation should have a corresponding method to get the value.

Oct 31, 2011 at 12:29 PM

To be honest, I don't think this is something we have considered before.  Your suggestion makes sense.  However, we try to use standard Microsoft attributes wherever we can (e.g. DisplayName, Description) and I don't see such a capability offered on those attributes? Does the strategy of sub-classing the attributes work for you?

Oct 31, 2011 at 2:19 PM

Hi Richard

Thank you for the response.

I completely understand your philosophy of using MS attributes where applicable.  I still can't believe that MS haven't added resource overloads to all of their attributes yet, as they have for some of the ones in the System.ComponentModel.DataAnnotation namespace.

As for subclassing the attributes, this is definitely something I could and have thought about looking into.  The only reason I held off is because I was unsure whether NakedObjects would support derived attributes or not.

Please can you confirm that if I derive my own attributes from the NakedObjects/MS ones, that the NakedObjects framework will use that attribute?

Oct 31, 2011 at 2:33 PM

Can't think of any reason why not;  I just tried it out with a simple example and it worked fine.

Oct 31, 2011 at 2:53 PM

Thanks for the response, and congratulations on writing such an great framework.