Localisation Rule descriptions

Localisation Rule descriptions

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


SealedClassSingleton posted on Wednesday, May 10, 2006

Hi,

I'm living in Belgium wherer some apps have to be multilanguage. Depending on the user's preferences the user's native language is selected (I cann't rely on the culture, since the choosen language has to be changed while the app is running, and all controls has to (re) localise themselves).

I'm using version 2.0 of the CSLA FW. When I do some validation, the databinding and errorprovider are working fine in the intended manner. However, I want to localise the description of the custom rules. Any idea what could be the best way to do this ?

I was thinking of  putting an XML fragment into the rule description and returning a localised attribute value depending on the current language when retrieving the error information from the IDataErrorInfo in the BusinessBase class.

At first sight, I don't see any possibility to do some transation on the UI layer, since the extended properties on the controls (e.g. error on errorprovider...) are'nt updated via the setError method...

Any suggestions / opinions ?

RockfordLhotka replied on Wednesday, May 10, 2006

I suggest that you use a resource file just like I do in CSLA .NET itself. The thread object has a UICulture property that controls the current culture to be used by the application. This defaults to the machine's culture, but you can change it through code.

The localization support built into Windows Forms is based on resource files and the UICulture as well, so this approach would let you use the features already built by Microsoft.

You can look at the CommonRules class in CSLA to see how I used the resource file to get at localized strings for the rule descriptions.

ksavoie replied on Tuesday, March 29, 2011

Hi

I know this is an old posting, but I'm looking into using the Localization in my custom Validation rules.

Would it be possible to get an example on how it would be done.  I've created my custom Validation rules ok and they work fine.  I using windows form (vb.net 2005 with CSLA 2.0), and my users have the option to change the language of the application.  With this I need to be able to show the error message in the different language.

I've used the following code to access the resources files:

 Dim mRS As New ResourceManager("frmMain", System.Reflection.Assembly.Load("frmMain"))

And in my custom rule this is the code I'm using:

e.Description = mRS.GetString("Invoice_Name")

When I do this, I get a Fetch failed (DataPortal.Fetch failed, Message: "Exception has been thrown by the target of an invocation.").  I've tried a few things, and when I thought I had the right code, I was getting a Serialization exception on the save.

So do you think it would be possible to get an example on localization to help me out?

Thanks

Kat

Copyright (c) Marimer LLC