Localization for Winforms from designmode?

I need to bind labels or items in a toolbox to variables in design mode. I am not using buit-in resources, not settings, so the Data section is not useful. I am taking values โ€‹โ€‹from XML which 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 non-compiled XML.

I know that programmatically I can do this, I create a method (like UpdateUI ()) and there I assign new values โ€‹โ€‹like this: this.tsBtn.Text = Class.Texts.tsBtnText;

I would like something I could do from design mode or in a more streamlined way than the current one. Is there any user control or extension?

0


source to share


3 answers


Aleksandar's answer is one way to achieve this, but in the end it will be very time consuming and won't do much good. The big question to ask is why you don't want to use the tools and features built into .NET and Visual Studio, or at least use a commercial third party tool? It looks like you are wasting (wasting?) A lot of time solving a problem that has already been resolved.



+1


source


Try to inherit the core win controls and override the OnPaint method. The example below is a button that has its text set to paint based on the value contained in its Tag property (assume you will use the Tag property to set the key that will be used to read the corresponding resource). Then you can find a way to read all cache resource lines from xml files (for example, the fictional MyGlobalResources class.



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

      

0


source


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

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

0


source







All Articles