netadictos
netadictos

Reputation: 7722

Localization for Winforms from designmode?

I need to bind labels or items in a toolstrip to variables in Design Mode. I don't use the buit-in resources not the settings, so the section Data is not useful. I am taking the values out from an XML that I map to a class.

I know there are many programs like: http://www.jollans.com/tiki/tiki-index.php?page=MultilangVsNetQuickTourForms but they work with compiled resx. I want to use not compiled XML.

I know that programatically i can do it, i create a method (for example, UpdateUI()), and there I assign the new values like this: this.tsBtn.Text=Class.Texts.tsBtnText;

I would like something i could do from Design Mode or a more optimized way than the current one. Is there any Custom Control out there or Extension?

Upvotes: 0

Views: 1839

Answers (3)

oldUser
oldUser

Reputation: 243

You can use satellite assemblies for localization and generate them using your XML file as a source for the translated entities. more about satellites http://msdn.microsoft.com/en-us/library/21a15yht(VS.71).aspx

sure it's not from design mode, but there's no way to do it this way with your restrictions.

Upvotes: 0

Scott Dorman
Scott Dorman

Reputation: 42516

Aleksandar's response is one way to accomplish this, but in the long run it's going to be very time consuming and won't really provide much benefit. The bigger question that should be asked is why do you not want to use the tools and features built-in to .NET and Visual Studio or at least use a commercial third-party tool? It sounds like you are spending (have spent?) a lot of time to solve a problem that has already been solved.

Upvotes: 1

Aleksandar
Aleksandar

Reputation: 1339

Try with inheriting basic win controls and override OnPaint method. Example bellow is a button that has his text set on paint depending on value contained in his Tag property (let suppose that you will use Tag property to set the key that will be used to read matching resource). Then you can find some way to read all cache resource strings from xml files (e.g. fictional MyGlobalResources class.

public class LocalizedButton : Button
{
    protected override void OnPaint(PaintEventArgs pevent)
    {
        base.OnPaint(pevent);
        this.Text = MyGlobalResources.GetItem(this.Tag.ToString());
    }
}

Upvotes: 0

Related Questions