Sample: Loading category descriptions in multiple languages
This sample demonstrates how to load English and French category descriptions in a single step operation, as well as a multiple step operation.
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 the store must support.
- Two-step operation: If your requirements change, and further language support is required later on, we 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.
Note: For this sample to work, the store we are using must support multiple languages. The Madisons starter store supports multiple languages.
Procedure
To load the English and French descriptions in the one-step operation:
(Developer) On a command line, go to the WCDE_installdir\bin directory.
- (Linux) Open a command line in the Utility server Docker container. 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:
- (Linux) ./dataload.sh ../samples/DataLoad/Catalog/MultiLanguages/wc-dataload-one-step-lang.xml
(Developer) dataload ..\samples\DataLoad\Catalog\MultiLanguages\wc-dataload-one-step-lang.xml
To load the English and French descriptions in the two-step operation:
(Developer) On a command line, go to the WCDE_installdir\bin directory.
- (Linux) Open a command line in the Utility server Docker container. 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:
- (Linux) ./dataload.sh ../samples/DataLoad/Catalog/MultiLanguages/wc-dataload-two-steps-lang.xml
(Developer) 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"/>
Note: We must specify the appropriate encoding to use for the languages we want to load. The character set is defined in the wc-loader-catalog-group-description.xml file as follows:
<_config:DataReader className="com.ibm.commerce.foundation.dataload.datareader.CSVReader" firstLineIsHeader="true" useHeaderAsColumnName="true" charset="ISO-8859-1"/>Verify that the categories and descriptions have been loaded by running the following SQL statements:
select * from catgrpdesc where catgroup_id in (select catgroup_id from catgroup where identifier like 'Womens Fashion%')We can also verify that the multi-language data has been loaded by viewing it in the Management Center or in the storefront.
Cleaning up the data
To remove the data loaded in this sample from the database, run the CleanUp.sql file in the /samples/DataLoad/Catalog/MultipleLanguages directory.