Localization in InfoPath form in SharePoint

Here is the one another way I could implement to localize the InfoPath form in my current SharePoint engagement.

1: create the number of localize xml file, you want to support. File name format must be locale.xml as “en-US.xml”, “en-GB.xml” etc.

2: In FormEvents_Loading function add code

        public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
try
{
//your Code
EstablishLocale();
}
catch (Exception ex)
{
e.CancelableArgs.Message = ex.Message;
}
}

3: Definition of EstablishLocale

        private void EstablishLocale()
{
string localeName = “en-US”; //which one you want to make dafault

            if (this.Application.Environment.IsBrowser)
{
localeName = SPContext.Current.Web.Locale.Name.ToLower();
}
FileQueryConnection dc = (FileQueryConnection)DataConnections["Resources"];
try
{
dc.FileLocation = localeName + ".xml";
dc.Execute();
}
catch (Exception ex)
{
// Eat any exceptions; they happen only when the resource file does not exist (we use the default file in this case).
}
}