Sample: Loading category descriptions in multiple languages
About this sample
In this sample demonstrates two ways to load multi-language category descriptions:- One-step operation: Load multi-language data in one step if you know the languages your store must support.
- Two-step operation: If your requirements change, and further language support is required later on, you can add additional language support in a second step.
To view the category descriptions in French in the Madisons storefront, select the French option in the language list on the Madisons home page.
Procedure
To load the English and French descriptions in the one-step operation:
- On a command line, go to the WCDE_installdir\bin directory.
- Open a command line in the . Change the directory to utilities_root/bin directory. For information about entering and leaving containers, see Running utilities from the Utility server Docker container.
- Enter the following command:
- ./dataload.sh ../samples/DataLoad/Catalog/MultiLanguages/wc-dataload-one-step-lang.xml
- dataload ..\samples\DataLoad\Catalog\MultiLanguages\wc-dataload-one-step-lang.xml
To load the English and French descriptions in the two-step operation:
- On a command line, go to the WCDE_installdir\bin directory.
- Open a command line in the . Change the directory to utilities_root/bin directory. For information about entering and leaving containers, see Running utilities from the Utility server Docker container.
- Enter the following command:
- ./dataload.sh ../samples/DataLoad/Catalog/MultiLanguages/wc-dataload-two-steps-lang.xml
- dataload ..\samples\DataLoad\Catalog\MultiLanguages\wc-dataload-two-steps-lang.xml
Verifying results
The wc-dataload-one-steps-lang.xml file calls the wc-loader-catalog-group-two-langs.xml configuration file, which has mappings for both English and French descriptions. The wc-loader-catalog-group-two-langs.xml file loads categories and descriptions from the CatalogGroupWithTwoLanguageDescription.csv source file.
In the two-step operation, the wc-dataload-two-steps-lang.xml configuration file loads categories from the CatalogGroupWithFirstLanguageDescription.csv source file. This CSV file contains the English names, short descriptions, and long descriptions of the categories. The wc-dataload-two-steps-lang.xml file then calls the wc-loader-catalog-group-description.xml configuration file to load the French names, short descriptions, and long descriptions from the SecondLanguageDescription.csv source file. The loader uses the CatalogGroupDescriptionMediator mediator to create descriptions for existing categories.
The French language ID is defined in the wc-dataload-two-step-lang.xml file as follows:<!-- Language id = -2 means French language -->
<_config:BusinessContext languageId="-2"/>
<_config:DataReader className="com.ibm.commerce.foundation.dataload.datareader.CSVReader" firstLineIsHeader="true" useHeaderAsColumnName="true"
charset="ISO-8859-1"/>
select * from catgrpdesc where catgroup_id in
(select catgroup_id from catgroup where identifier like 'Womens Fashion%')
You
can also verify that the multi-language data has been loaded by viewing it in the Management Center
or in the storefront.