Samples > Data load utility samples
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 the 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.
For this sample to work, the store you 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:
- Open the command-line interface and navigate to the appropriate directory:
- WC_INSTALL/bin
- WCDE_INSTALL\bin
- 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:
- Open the command-line interface, and navigate to the appropriate directory:
- WC_INSTALL/bin
- WCDE_INSTALL\bin
- 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
Verify 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"/>
You must specify the appropriate encoding to use for the languages you 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%')You can also verify that the multi-language data has been loaded by viewing it in the Management Center or in the storefront.
Clean 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.
Previous topic: Sample: Changing the parent of a subcategory
Next topic: Sample: Adding image attachments to categories and catalog entries
Related reference