Hi,
We use CSLA 3.6.2 on windows 7 with vs2010. Our app can be run in multiple languages with English as our primary language. Our problem is that when the app's culture is set to something other than English (de-DE), the string returned from a StringRequired validation is an English property name followed by the non-English part of the message. We're expecting the whole message to be in the language of the app's culture. Here are the details:
We have this property setting:
public static PropertyInfo<string> TitleProperty = RegisterProperty(new PropertyInfo<string>("Title", AnnouncementActivityMessages.Title, string.Empty));
We have this validation rule:
ValidationRules.AddRule(CommonRules.StringRequired, new DecoratedRuleArgs(TitleProperty));
This is the english resource for AnnouncementActivityMessages.Title
<data name="Title" xml:space="preserve">
<value>My Title</value>
<comment>Property on the business object</comment>
</data>
This is the German resource for AnnouncementActivityMessages.Title
<data name="Title" xml:space="preserve">
<value>Titel</value>
<comment>Property on the business object</comment>
</data>
When we run this in English, everything is great. But when we switch the app to run in another language (anything other than English) and run through the validation, we get the following error message generated:
My Title erforderlich
Another interesting twist is that if I do an IISReset on my webserver and refresh the page, it starts to work and as I move to a different part of the app, where we're validating a title for a different business object, I see the original problem again.
Has anyone else experienced this problem?Yes, that is how PropertyInfo is coded.
PropertyInfo sets the value when the PropertyInfo is created and will thus only have the "first" value available. There is (even up until now) no dynamic read that will support switching of locale within the running application.
Thank you Jonny. I think I understand what you're saying, but I don't understand how CSLA seems to know that we're working in the German language (because the message contained the German translation from the CSLA resource strings), yet when getting my local resources for the friendly field name, it doesn't have the culture correct.
I don't know enough about it, but it may be that in our environment, we've created a CSLA service so that requests get handled via the service. I wonder if when the service starts this might have something to do with properties being loaded with their English translations.
If that's the case, it may be far easier for us to simply change from using the CommonRules to instead use custom rules (which we have written some for special situations), and this would allow us to return what we need.
Again, really appreciate the quick and insightful response
Quite simply - the rule reads the message text from Csla satellite resources if found for the current thread language.
PropertyInfo.FriendlyName is set when the PropertyInfo is created (when the class is instantiated the first time) and will keep that value for the time the application is running.
Ah, I see. Thanks very much. We're going to take a different approach with it.
Copyright (c) Marimer LLC