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....
LVL 8
CamilliaAsked:
Who is Participating?
 
Alexandre SimõesConnect With a Mentor Manager / Technology SpecialistCommented:
I have an idea to implement on this matter but didn't had the time to implement it...

It should work with one db table and a component that would work as an extender provider.
http://msdn2.microsoft.com/en-us/library/d6c1xa43(vs.80).aspx

DATABASE:
The datamodel for this is very simple, just a table with a code column (unique & varchar) and several columns (string) one for each language supported. name the columns the language code like ''en-EN"


EXTENDER PROVIDER:
If you read the article above you know that Extender Providers add properties and functionality to the controls you have on the form.
You can/have specify which controls you want to interact with.

This Extender Provider will have to add a property to the handled controls that will represent a code (string). This code will identify the row on the db table. Lets name this property "LocalMsgCode".

So, thinking simple, lets focus on label controls.
what the extender must do is pick each control LocalMsgCode property value, get the application localization code and request the string row/column value on the db table that matches the query.
The you just have to set the label text property with the result.

If the db doesn't have a column for the requested localization you should have a property on the extender that specifies the default local.

You can even use this model for all kind of interaction with the user like messageboxes for example... request the string by its code and it will retrieve the message.

The code should be string so you can group messages with prefixes... but you can go a little further and implement a Id -> PId recursive relation within the table to create groups and show them on a tree control.

I really don't have the time know to implement this but isn't hard at all... 1 day should do it all.

Cheers,
Alex
0
 
CamilliaAuthor Commented:
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.
0
 
Alexandre SimõesManager / Technology SpecialistCommented:
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.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
CamilliaAuthor Commented:
let me read it and wrap my head around it.

Thanks
Kamila
0
 
CamilliaAuthor Commented:
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..
0
 
Alexandre SimõesManager / Technology SpecialistCommented:
Yeah, maybe you can implement a way using the same database.
0
 
CamilliaAuthor Commented:
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??
0
 
Alexandre SimõesManager / Technology SpecialistCommented:
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.
0
 
CamilliaAuthor Commented:
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?
0
 
Alexandre SimõesManager / Technology SpecialistCommented:
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
0
 
CamilliaAuthor Commented:
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.
0
 
CamilliaAuthor Commented:
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??
0
 
CamilliaAuthor Commented:
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??
0
 
CamilliaAuthor Commented:
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.
0
 
CamilliaAuthor Commented:
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.
0
 
Alexandre SimõesManager / Technology SpecialistCommented:
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... :)
0
 
CamilliaAuthor Commented:
Got it fixed. Thanks for sticking with this. Will keep this thread open for few more days just in case.

Kamila
0
 
CamilliaAuthor Commented:
Thanks for your help. Works great.
0
 
Cool CurrentCommented:
One issue though is that extender provider wont work for datagridview column headers and a few other controls
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.