Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Localization but Database method for WinForm

I used this code; http://msdn2.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_t

 I converted that to VB.Net, tweaked it a little bit for my ASP.Net app and it works great.

Is there a database localization method similar to that for windows form? I've been googling and I've mostly found RESX method:  http://www.ondotnet.com/pub/a/dotnet/2003/08/25/globalization_pt1.html

*** I have a localization table like that first link and just need to read the text from that table...

any ideas would be great....
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

let me read it. Thanks for responding. That MS article for asp.net works great. Hope I can get this one working for windows. Will post back.
This is an architecture I designed to be able to implement multi-language on every single string I need to display to the user... being that on controls, messages, exceptions, whatever...

A simple implementations would be simply using the Language property of the form and translate the controls.
let me read it and wrap my head around it.

Thanks
Kamila
It sounds similar to the asp.net method. I do have the table with unique ids. ASP.Net uses GetObject like this:
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsLocalization.aspx

>> what the extender must do is pick each control LocalMsgCode property value,...

Yeah, that ASP.Net link has all this coded for ASP.Net.

Let me read the provider link and see where that would get me..
Yeah, maybe you can implement a way using the same database.
ok, i read that article, googled for more examples to get a better understanding and this is a good example:
http://www.emoreau.com/Entries/Articles/2004/10/Extender-providers.aspx

This is what i dont understand: how does the extender help in localization??
So, I have a Form with 2 labels. I have the table with 2 unique rows. I create the extender. Now what? where does going to the database and getting the value for each label fits in all this??
The extender does that...
One extender can interact with every single control on your form.

Currently I'm using an extender to apply security just like I've described for localization.
I specify the security code for the action the control executes (if any) and the extender will enable or disable it.
i'm probably beating this to death. I'll download the code and try it.

>>One extender can interact with every single control on your form.
    but for each label, i need to call the database to get the corect value for that specific label..right? So, the extender is a property for all the labels on a form..i need to bind the value to an extender property for each label?
Wait... your getting the Extender functionality all wrong...
I believe you need to make a small test with it, a simple one, just to get the hang of it.

"the extender is a property for all the labels on a form"
The Extender isn't a property, the extender is a Component (not a control, it shows on designer like an ImageList on the bottom).
The extender add properties and functionalities to controls and it can interact with them.
From the Extender component you can:
1. "loop" through all the controls you want
2. get the value they have on the Code property (added by the extender), do nothing if no value
3. get the string from the database based on the code
4. Set the control text

Once the Extender is applied to the form it will do this for every control type you specified as supported.


This may seem a bit complex said like this but it isn't.
It's not the easiest thing but once you get the hang of it it's pretty straight forward.

Do some standalone testing.

Cheers!
Alex
I stepped thru that sample code. I think i know what you're doing. That code basically does what you're describing. I will need to tweak it to go to the database and get the "text" for the label..Your step 3 above

Thanks for sticking for this. I will keep the question open few more days just in case. will post back.
I played around with that sample code. Then I changed the sample code to C# (i'm trying this in C#). I added a class library, added that code to a class. Named it cExtenderProvider. I added a reference to it in my project.

Now, how can I drag and drop this to the form?? I looked at the Toobar, under Components, i dont see it there. I tried to drag and drop the class..of course it didnt work. I dragged a ToolTip and that worked fine..

how can I do this??
I closed VS and opened it. Now I see it in the toolbar but it has : There are no usable controls in this group.Drag an iten onto this text to add it to the toolbox.

What to drag??
dont know what i did but now i see the class name under the Component tab :
cExtenderProvider
   pointer
   ExtenderProvider

But both items are greyed out. I can rename ExtenderProvider but cant drag and drop.
I think i fixed it. I had created the component using a "class". I deleted it. Added a "component" item.

Now I can see it in the toolbar and it's not greyed out.
Sorry I didn't replied...
Sometimes VS have some troubles adding the controls to the toolbox.
The best option is having the controls on a separated project, somehow I never had that kind of problems when my controls were on a different project than the on I was going to use them.

No great answer for you on this one, sorry...

Cheers... 2AM... time to bed... :)
Got it fixed. Thanks for sticking with this. Will keep this thread open for few more days just in case.

Kamila
Thanks for your help. Works great.
Avatar of Cool Current
Cool Current

One issue though is that extender provider wont work for datagridview column headers and a few other controls