How-to Localize a SharePoint Commerce Services Site

This how-to provides instructions to illustrate how you can localize the Product Query Web Part of the default site in SharePoint, as well as the underlying catalog data that feeds it. Many web parts in Commerce Server leverage XSL templates which transform serialized business entities adding layout and other text. For this sample, it is assumed the following software has been installed in the server (Windows Server 2008):

  • The Japanese Language Interface Pack (LIP):

  • The Windows SharePoint Services Language Pack (Japanese)

  • Windows SharePoint Services 3.0 Language Pack Service Pack 1 (Japanese)

  • 2007 Microsoft Office Servers Service Pack 1 (Japanese)

To localize the Product Query web part, we will perform the following tasks:

  1. Create a virtual catalog for prices in the new currency

  2. Add a pricing rule to the virtual catalog for the new currency

  3. Create localized site variations in Windows SharePoint Services

  4. Configure SharePoint Commerce Services to use the new virtual catalog

  5. Change the language-dependant details in web part templates

Create a virtual catalog for prices in the new currency

To create a virtual catalog, perform the following tasks:

  1. Open the Commerce Server Catalog Manager and connect to the Default Site.

  2. Under Tasks, select Create a New Virtual Catalog.

  3. Set the currency to Yen and click Next.

    Dd464369.062e9148-5491-488d-9768-1ca58548c562(en-US,CS.90).gif

  4. In the Catalog Languages window, add Japanese to the catalog languages and click Next.

    Dd464369.85c07c06-3516-48b4-9a27-eea399f87011(en-US,CS.90).gif

  5. In the Virtual Catalog Summary window click Create.

    Dd464369.fa4fa28f-fb44-4b3b-80d4-c852452296ff(en-US,CS.90).gif

  6. Add products to the new catalog in the wizard and click Create.

    Dd464369.badfabff-f8c7-407a-8095-384f70de61a0(en-US,CS.90).gif

  7. Rebuild the new Virtual Catalog.

Add a pricing rule to the virtual catalog for the new currency

For this how-to the new pricing rule will multiply the base price by a currency exchange rate.

To create a price rule, perform the following tasks:

  1. Open the Commerce Server Catalog Manager and connect to the Default Site.

  2. Click On the Rules tab, and then click the Add button.

  3. Select the catalog to apply the rule upon and click Next.

  4. In the Rule Properties window, for Rule type select Pricing, for Pricing rule type select Add Percentage, and for Price Amount type the exchange rate and click Create.

    Dd464369.1aaaa502-73ce-4d37-9370-3548a60045f5(en-US,CS.90).gif

  5. From Catalog Manager, right click on the virtual catalog, and from the context menu select Edit Catalog Properties.

  6. Click the Rules tab; you should now see your Pricing Rule listed.

    Dd464369.c685549a-b132-40ac-b5a6-4a6b1a6ed3e1(en-US,CS.90).gif

Create localized site variations in Windows SharePoint Services

To create a localized site variations in Windows SharePoint Services, perform the following tasks:

  1. In the default site (in this example it is the root site of the site collection), click Site Actions > Site Settings > Modify All Site Settings.

    Dd464369.62e00807-5002-43ad-8d3c-45e9a591a0db(en-US,CS.90).gif

  2. Click on Variations and set location to root (/), and then choose to copy resources.

    Dd464369.1f19b40a-3adc-4cfc-b515-2814ecc8b1ee(en-US,CS.90).gif

  3. In Site Settings, click Variation Labels and create a new label.

  4. Click Create Hierarchies.

    Dd464369.11b7488a-7dfb-42a0-b6d1-3d0eab2b3998(en-US,CS.90).gif

The web site structure now has English and Japanese site variations, which are SharePoint sub-sites. Now that the current locale is set, please note two characteristics of the Japanese site variation. First, the Japanese version of the Default Site retrieves localized strings from resources files for label controls and other components of the solution, such as web part descriptions. Second, note that the current locale of a web site is included in the calls that SharePoint Commerce Services make to the Commerce Foundation API. Thus, values of localized catalog properties are retrieved.

Configuring SharePoint Commerce Services to use the new virtual catalog

In this step we configure the Japanese site variation to access the previously created virtual catalog. The intent is to retrieve product prices in Yen.

To configure SharePoint Commerce Services to use the new virtual catalog, perform the following tasks:

  1. In Site Settings, click Manage Site Content and Structure.

    Dd464369.8bf16ca4-2a9c-407f-9aab-85f83c21a0f9(en-US,CS.90).gif

  2. Expand the Japanese site variation, and click on Channel Configuration.

    Dd464369.b8639e6c-7c79-46a0-8d42-dc7ec0f48fa4(en-US,CS.90).gif

  3. We now set the channel's value to Default and the DefaultCatalog's to AdventureVirtual.

  4. Click on the cell positioned under the Value column and on the Channel row.

  5. Choose Edit Properties.

    Dd464369.d84922c9-05fa-45fd-98c8-453721bb83fe(en-US,CS.90).gif

  6. Change the content type (コンテンツ タイプ) of this list item to ChannelStringContentType. In the Value field, enter Default and then click Ok.

    Dd464369.ad5003f4-6241-4864-9964-db19120a09a6(en-US,CS.90).gif

  7. Click on the cell positioned under the Value column and on the DefaultCatalog row.

  8. Choose Edit Properties. Change the content type (コンテンツ タイプ) of this list item to ChannelStringContentType.

  9. In the Value input field, enter AdventuresVirtual, and click OK.

    Dd464369.138e866e-7beb-4a6d-aad1-f9e042ac23db(en-US,CS.90).gifDd464369.1b4c1191-d7a6-48f4-a51c-3b7d0c3c999d(en-US,CS.90).gif

We have now configured the Japanese site variation to access the Default channel and the AdventuresVirtual catalog. The web parts in the Japanese site variation will now reference the virtual catalog with its locale and pricing changes, whereas the English site variation references the base catalog.

Changing language-dependant details in web part templates

Localizing a template for a web part involves of updating string constants, currency formats and other language-dependant details in its template file under the Commerce Server Templates document library in the site variation.

The next step is to change the price format in the Product Details Web Part. The price itself is already expressed in Yen in the virtual catalog by the percentage rule.

Dd464369.22e765c4-17ee-4d5a-a641-0fe6e777b3a2(en-US,CS.90).gif

To change the price format from "$#0.00" to "¥#,##0" we update the Sample_ProductQuery template. We may download it as a file from the ProductQuery folder in the Commerce Server Templates document library, or we may modify the template of the Product Query Web Part directly in the Category page. We choose the latter option.

To change the price format, perform the following tasks:

  1. In the Japanese site variation, navigate to the Boots department (ブーツ).

  2. Edit the page, and select Modify the Product Query Web Part. The properties bar will appear on the right side of the page.

  3. Edit the Template Details. In the Webpage Dialog, locate the fragment

    <xsl:value-of select="format-number($listPrice, &quot;$#0.00&quot;)" />
    

    and change it to:

    <xsl:value-of select="format-number($listPrice, &quot;¥#,##0&quot;)" />
    

4.Click Ok, and in the properties bar, click Apply, Save and then click Ok.

5.Publish the page (the option is available in MOSS, but not in WSS).

Notice now that the prices are formatted differently:

Dd464369.87bbc214-e3f9-4398-91b7-2728668e6ad9(en-US,CS.90).gif