Localization In InfoPath


Introduction to Localizing InfoPath Form Templates

    In common design practice is to embed text directly in the form.However, when you need localized forms, a different approach is required. The typical design pattern for localization is to move all strings into locale-specific resource files and load the appropriate strings at run time

Designing Your Form
 The following step will explain step by step creating simple Infopath ffrom
  1. Go to start -> All Program ->Microsoft Office ->Microsoft Info Path Designer
  2. File -> New -> Crate New Blank Form.
  3. Desigin a form like this

 

Figure 1

Localizing the Form

       After your form template works as you expect, you can start to implement localization for your form. This consists of five main stages
  1. Creating an .resx resource file that contains the display strings for the language of your locale, and then creating additional .resx resource files for each locale your form supports.
  2. Adding the .resx resource files to the form template as resources, and then defining a secondary data source to enable code and formulas in InfoPath to access the data contained in the resource files.
  3. Adding code to detect or specify the current locale, and then load the appropriate localization resource file.
  4. Converting controls on the form template and adding code or formulas to read display strings from the XML resource files you created.
  5. Deploying and testing the localized form template.

Creating the Localization Resource Files for the Form

        After your form template operates as expected, you need to create the localization resource files that contain the display strings for your form, and then define a secondary data connection that will be used to access the data in the files.

Creating a Default Localization Resource File

  1. Go to Project Explorer and right click and select Add New item

  2. Select Resource file under Template
  3. Rename "Resource1.resx" to "en-US."
  4. modifying the like this and save                                  Figure2
  5. Repeating step 2 to 4 and save the file like sp_Sp,resx                            Figure 3

Adding the Localization Resource Files to Infopath and Defining Their Data Connection

After you complete all localization resource files, you need to add them to the form template as resource files.
To add the localization resource files to the form template.
  1. Open the form template in design mode.
  2. Click On Data then following the Image bellow
    Figure4
  3. Click add button and select "en-US..resx" where you save 
  4. Similarly you need to add "sp_Sp,resx"                                                    click ok                                                               Figure 5

Adding a Secondary Data Source to the Form

This design pattern uses a data connection defined as a secondary data source to connect to the localization resource files and read data from the files.
To add a secondary data source to retrieve data from localization resource files
  1. On the Tools menu, click Data Connections, and then click Add.
  2. Click Create a new connection to, click Receive data, and then click Next.
  3. Click XML document, and then click Next.
  4. Click Resource Files, select your default localization resource file, click OK, and then click Next.
  5. Name the data connection Resources, ensure that the Automatically retrieve data when form is opened check box is selected, and then click Finish, as shown in Figure 6.
Figure 6. Adding a secondary data source

Adding a secondary data source




 

 


No comments:

Post a Comment