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:
Create a virtual catalog for prices in the new currency
Add a pricing rule to the virtual catalog for the new currency
Create localized site variations in Windows SharePoint Services
Configure SharePoint Commerce Services to use the new virtual catalog
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:
Open the Commerce Server Catalog Manager and connect to the Default Site.
Under Tasks, select Create a New Virtual Catalog.
Set the currency to Yen and click Next.
In the Catalog Languages window, add Japanese to the catalog languages and click Next.
In the Virtual Catalog Summary window click Create.
Add products to the new catalog in the wizard and click Create.
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:
Open the Commerce Server Catalog Manager and connect to the Default Site.
Click On the Rules tab, and then click the Add button.
Select the catalog to apply the rule upon and click Next.
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.
From Catalog Manager, right click on the virtual catalog, and from the context menu select Edit Catalog Properties.
Click the Rules tab; you should now see your Pricing Rule listed.
Create localized site variations in Windows SharePoint Services
To create a localized site variations in Windows SharePoint Services, perform the following tasks:
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.
Click on Variations and set location to root (/), and then choose to copy resources.
In Site Settings, click Variation Labels and create a new label.
Click Create Hierarchies.
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:
In Site Settings, click Manage Site Content and Structure.
Expand the Japanese site variation, and click on Channel Configuration.
We now set the channel's value to Default and the DefaultCatalog's to AdventureVirtual.
Click on the cell positioned under the Value column and on the Channel row.
Choose Edit Properties.
Change the content type (コンテンツ タイプ) of this list item to ChannelStringContentType. In the Value field, enter Default and then click Ok.
Click on the cell positioned under the Value column and on the DefaultCatalog row.
Choose Edit Properties. Change the content type (コンテンツ タイプ) of this list item to ChannelStringContentType.
In the Value input field, enter AdventuresVirtual, and click OK.
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.
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:
In the Japanese site variation, navigate to the Boots department (ブーツ).
Edit the page, and select Modify the Product Query Web Part. The properties bar will appear on the right side of the page.
Edit the Template Details. In the Webpage Dialog, locate the fragment
<xsl:value-of select="format-number($listPrice, "$#0.00")" />
and change it to:
<xsl:value-of select="format-number($listPrice, "¥#,##0")" />
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: