Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
229
Translate UI
posted

Hi all,

I am a newbie here, doing my first steps into Infragistics.
One of the things I cannot find is how I could translate the user-interface (filtering/ sorting etc. ) of UltraGrid.
What would be the best scenario to do this?

tia,

 

Erik Visser 

 

 

  • 125
    Verified Answer
    posted

     Hi, here is my solution to do that:

    Strings for controls are located in resources. Help link 

     ms-help://INFRAGISTICS_NETEN82CLR2_HELP/NetAdvantage_NETEN82CLR2/Win_NETEN82CLR2/WinElements/Win_Assembly_Resource_Strings.html

    contains description of string you can translate.

    I have a txt file which contains

    MoreWindowsDlgClose Закрыть
    MoreWindowsDlgCloseWindows Закрыть окно(а)
    MdiCommandCloseWindows Закрыть все окна

     

    where first word is Key of a string that need to be translated

    " " splits translation(in this case - russian)

     

    This file is located in resources.

    then in code i have an util class which contains few methods

     

    public static void LocalizeControls()
                {
                    Infragistics.Shared.ResourceCustomizer cust = Infragistics.Win.UltraWinGrid.Resources.Customizer;
                    StringReader r = new StringReader(Properties.Resources.translate);//this is txt file

                    while (true)
                    {
                        string line = r.ReadLine();
                        if (line != null)
                        {
                            KeyValuePair<string, string> val = GetKeyValue(line);
                            cust.SetCustomizedString(val.Key, val.Value);
                        }
                        else
                        {
                            break;
                        }

                    }

                    cust = Infragistics.Win.UltraWinTabbedMdi.Resources.Customizer;
                    r = new StringReader(Properties.Resources.tabbedmdi);

                    while (true)
                    {
                        string line = r.ReadLine();
                        if (line != null)
                        {
                            KeyValuePair<string, string> val = GetKeyValue(line);
                            cust.SetCustomizedString(val.Key, val.Value);
                        }
                        else
                        {
                            break;
                        }

                    }

                    cust = Infragistics.Win.UltraWinToolbars.Resources.Customizer;
                    r = new StringReader(Properties.Resources.toolbar);

                    while (true)
                    {
                        string line = r.ReadLine();
                        if (line != null)
                        {
                            KeyValuePair<string, string> val = GetKeyValue(line);
                            cust.SetCustomizedString(val.Key, val.Value);
                        }
                        else
                        {
                            break;
                        }

                    }

                    cust = Infragistics.Win.Misc.Resources.Customizer;
                    r = new StringReader(Properties.Resources.misc);

                    while (true)
                    {
                        string line = r.ReadLine();
                        if (line != null)
                        {
                            KeyValuePair<string, string> val = GetKeyValue(line);
                            cust.SetCustomizedString(val.Key, val.Value);
                        }
                        else
                        {
                            break;
                        }

                    }
                }


            }

            public static KeyValuePair<string, string> GetKeyValue(string line)
            {
                string key;
                string value;

                     key = line.Substring(0, line.IndexOf(" "));
                    value = line.Substring(line.IndexOf(" ") + 1, line.Length - line.IndexOf(" ")-1);
              
                return new KeyValuePair<string, string>(key, value);
            }

    when a program starts you call the LocalizeControls() method