Wednesday, April 3, 2013

Localization [Multilingual fuctionality] of Infopath forms-13 for SharePoint 13 using XML a resource file

To creata a multilingual Infopath forms which is to be used in the Sharepoint site here are the below steps.

Software used are Infopath Forms 13 and Sharepoint 13

Open the Infopath form Designer select  a Blank form template.Publish it to the required sharepoint 13 site as content type or to form library .

Create an XML file called "Resource.xml" from which we pic the language specific text to to displayed in the Sharepoint site .

Your xml file can look like below :::


<?xml version="1.0" encoding="UTF-8"?>
<
LangSettings><
Languages><
Language Name="English" Code="ENG"/><
Language Name="Spanish" Code="SPA"/><
Language Name="French" Code="FRE"/></
Languages><
Labels><
Label Name="Name"><
LocalLabel Code="ENG" Value="First Name"/><
LocalLabel Code="SPA" Value="Nombre"/><
LocalLabel Code="FRE" Value="Nom"/></
Label> <
Label Name="Phone Number"><
LocalLabel Code="ENG" Value="Phone Number"/><
LocalLabel Code="SPA" Value="Ph no in Spanish "/><
LocalLabel Code="FRE" Value="Ph no in German"/></
Label> </
Labels><
Colors><
LocalColor ID="Blue" Code="ENG" Value="Blue"/><
LocalColor ID="Blue" Code="SPA" Value="Azul"/><
LocalColor ID="Blue" Code="FRE" Value="Bleu"/><
LocalColor ID="Green" Code="ENG" Value="Green"/><
LocalColor ID="Green" Code="SPA" Value="Verde"/><
LocalColor ID="Green" Code="FRE" Value="Vert"/><
LocalColor ID="Red" Code="ENG" Value="Red"/><
LocalColor ID="Red" Code="SPA" Value="Rojo"/><
LocalColor ID="Red" Code="FRE" Value="Rouge"/><
LocalColor ID="Yellow" Code="ENG" Value="Yellow"/><
LocalColor ID="Yellow" Code="SPA" Value="Amarillo"/><
LocalColor ID="Yellow" Code="FRE" Value="Jaune"/></
Colors></
LangSettings>

To add the XML file into the Infopath open the Infopath form-->DATA-->From Other Sources-->From XML files.

Browse the XML file and add it .Click finish for finish close the window for everything .

Below are the different scenarios in Infopath forms where the multilingual func has to be taken care of

First add a drop down list to select the required language of the forms.Use the resource as data source and select code as value field and Name as display field .

  1. LABEL
We are not going to use the  label here.Instead add a "Calculated field"

it opens in a pop up Pick the "Name " field to be displayed in such a way that add conditions like 
Display "Name " from resource file where "label=Name" and where "Code=Selected language"
the equation will look like below

@Value[@Name = "First Name" and @Code = LanguageChoice] 

2) For Drop Down display

use the resource file "color" field
Bind the drop down with the "color" tag of resource file and filter in such a way as to get only the data for partilar language .This is done by coparing with the selected language to ID field


3)For Button

There is no direct way with the button

You got to add 3 different buttons  for three different language having same id  but different display name
on clicking the each button add a rule to format the control
In the conditon
  •  Hide hide control
  • Condtion will be like "slected language  if not equal to ENG" same for other language too expect the last condition will be SPA or FRE

 

No comments:

Post a Comment