Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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).
}
}
Comments
Anonymous
January 14, 2009
Can you tell the structure of locale.xml fileAnonymous
July 24, 2011
Hi can u send me the sample full coading this loading event.. i have added structure of the Xml file.... thanks <?xml version="1.0" encoding="utf-8"?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="www.w3.org/.../namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <!--<data> nodes go here.--> </root>