How To: Create a Multilingual InfoPath Form

An Oldie but a Goldie. Due to popular demand, this is definitely a blog post to bring back. In case you haven’t noticed, a lot of content I had on my blog is gone; a result from the re-branding exercise the blog underwent in December. Never trust a company to take content backups for you. I am working on re-publishing at least the popular ones.

The Background

I came across this requirement back in 2007 (I feel old re-writing this…) when I first started working with SharePoint 2007 (or MOSS) and InfoPath 2007. Back then I was quite a rookie and I just took the advice from a former colleague that the best way to create multilingual forms is to use code. Yes, code behind InfoPath forms. Shivers came up just thinking about code behind InfoPath forms.

Anyway, back then we had the same requirement for a project in SharePoint 2013 and web based InfoPath forms. And code was not only not an option, but I refrain from using code with InfoPath. In my opinion, if you have to write a single line of code in InfoPath, it is not the right technology and you should look elsewhere.

The Solution

If code is not an option, what else is there? Well there is an easy and pretty straight forward no-code solution for multilingual InfoPath forms. Note that the blog post was done using SharePoint 2010 and InfoPath 2013, but works the same way in SharePoint 2013. I just didn’t have a 2013 environment handy at the time of writing.

There is two components we need. The form itself and a SharePoint list, which will hold all our field labels in various languages.

Component One – The Form Labels List

  1. Create a list using the Custom List template in the SharePoint site you want to host the form in;
  2. We will need 3 columns in that list, so go into the list settings (or do it through the ribbon bar) and create them as outlined below:
      1. Label ID: Single Line of Text; Mandatory (I used the Title column and renamed it); This will hold the labels ID, not the value we want to display for each language. So if we have a field in our form called “First Name” or “Vorname” in German, the label ID will be “FirstName”.
      2. Language: Choice; Drop Down; Mandatory; Values are the languages you want to provide (for this example I used “English” and “German”); This will allow us to tell the form which language the label text is in. We will us it later to filter the value in our form.
      3. Label Text: Single Line of Text; Mandatory. This is the actual text of the label. So if the label for “FirstName” should be in German, the label text value will be “Vorname”

  3. Now we will pre-fill the list with data. For our scenario we are planning with 3 fields in our form which are First Name, City and Date and Time. Go to your list and create a new item.  
  4. For the label “First Name” put in the following values:
    1. Label ID: “FirstName”
    2. Language: “English”
    3. Label Text: “First Name”;
  5. At this stage we have the English label defined. For the German label repeat Step 3-4 with the following values:
    1. Label ID: “FirstName”
    2. Language: “German”
    3. Label Text: “Vorname”
  6. Ok, since the form will only cater for 2 languages, we are done with the FirstName label. Now repeat Steps 3-5 for the labels City and DateTime (German values are “Stadt” for City and “Datum und Uhrzeit” for DateTime).

For a form that will support 4 languages you would have 4 entries per label ID, for 5 languages 5 entries and so on.

Alright, the first part is done. Easy, wasn’t it? No line of code so far and all through the UI. Now, let’s get started with the form.

Component Two – The Form

Fire up InfoPath. I used SharePoint 2010 in my example, but designed the form in InfoPath 2013. Create a new browser base form and we can get started.

  1. Insert a 2×4 table underneath the title area and drop a Drop Down (LanguageSelection), a Text Field (FirstName), another Drop Down (City Selection) and a Date/Time (DateTime) control into that table, so it looks like the example below and make sure you name your fields accordingly in the form data section. The sequence of the fields on the form data section mirrors the sequence of the controls in the table.
  2. Next, we will configure the language selector. Right-click on the first drop down in your table and select Drop-Down List Box Properties. Add two entries to the list of list box choices; English and German. Make English the default and remove the default “Select…” option.
  3. Click OK and return to your form. In the cells left of each box, insert a Calculated Value control, except for the first line. Those controls will be used for our labels. When you add them you will be asked to provide an XPath expression. Leave this part empty for now and click OK. Your form will look like so:
  4. At this stage, we have our list that holds the label information and a form with is basic structure. Now we need to connect the list to the form and then configure the Calculated Value controls to show the label text according to what was selected in the language drop down at the top of the form.
  5. Now go to the Data tab in the ribbon and select the From SharePoint List option. We are now going to hook up the list to the form. Follow the wizard, make sure that you select the Form Labels list in the second screen. On the next screen you will have the option to select fields that you want to use in the form. Make sure you select the fields shown in the screenshot:
  6. Click Next, Next and Finish.

Ok, so now we have the list connected to the form, but how does that make our form multilingual? So here are the final steps to make your form multilingual.

  1. Right-click on the first Calculated Value control and select Calculated Value Properties
  2. Click on the formula button
  3. Select Insert Field or Group
  4. In the Select a Field or Group window change from the Main data source to your list data source. In my example the data source is called FormLabels
  5. Drill down into the dataFields group and select the Label Text field
  6. Then click on Filter Data
  7. At this stage, the data source would return all the Label Text fields from our list but only display the first one that we put in. We now want to filter the result set from our list by telling it which language we need and which label. The label ID we’ll have to hardcode, which is fine. This usually doesn’t change at all. For the language, we want it to be dynamic, so we will use the language drop down’s value for our filter.
  8. In the Filter Data dialog click Add to create a new filter
  9. For the first part of the filter rule, select the field Label and the condition will be “Label is equal to FirstName”. FirstName is the value of our label ID and since we want the first label to be the FirstName label, we tell it the corresponding label ID. Type in FirstName
  10. Then click on And to add another condition to the rule
  11. Select Language from the list field options, is equal to as the condition and in the third field choose Select Field or Group
  12. In the Select Field or Group dialog change back to your main data source and select the Language field
  13. Click OK and make sure your rule looks like the screenshot below
  14. Click OK until all the dialog windows are all closed
  15. Now repeat step 1-14 for the other two Calculate Value controls. 
When repeating step 9, make sure you replace the label ID with the corresponding field’s label ID (City for the City label and DateTime for the Date and Time label) Ea. “Label is equal to City”

Time to test the form. Hit F5 or click on the preview button in InfoPath. It should load with the English labels, as English is our default value in the language drop down.

Now select German from the language drop down and the labels will change to German.

Hopefully all working as expected. And all that without a single line of code, just using SharePoint and InfoPath features.

The same principle applies to InfoPath 2010, 2013 and SharePoint 2010, 2013 as well as InfoPath Filler forms.If you want to use InfoPath web based forms, like in this example, you will require the Enterprise features of SharePoint.

One more thing, the values of drop down controls are still in English in our example, but the same rules based filtering can be applied to the drop down values. Just make sure you maintain those values in a SharePoint list. The administration of the labels and drop down values will be so much easier.

Tags: , ,

No comments yet.

Leave a Reply