There are several ways to set up a single product catalog that contains content for multiple locales. This section describes one way, which is to make every locale-sensitive property of every item in the catalog a multi-valued property that has key/value pairs for each locale. For example, if each item in the catalog has a property shortDescription of type String, this description String needs to be translated into a different language for each locale your site serves. The item product.shortDescription needs to have a map that looks like this:

Key

Value

en_US

This is a very protective and fashionable helmet.

fr_FR

Ceci est un très protectif et chic helmet.

jp_JP

(translated into Japanese)

Displaying data for this item in a JSP requires one extra step: adding logic that evaluates the user’s locale to display the correct value from the property’s map. For example, instead of accessing a product from a JSP where the product parameter contains the product repository item from the locale-specific catalog repository:

<dsp:valueof param="product.shortDescription"/>

you now access items

<dsp:valueof param="product.shortDescription.en_US"/>

where the product parameter contains the product repository item that is take from the single repository of all the language catalogs.

To set up a single product catalog repository, you must modify your database tables. Again, there are many different ways to do this. One solution is to remove all the locale-specific properties (such as display_name, description, long_description) and place them in multi-value tables. For example, the current dcs_product table looks like this:

Table Name: dcs_product

product_id
(primary key)

VARCHAR(40)

NOT NULL

version

INTEGER

NULL

creation_date

TIMESTAMP

NULL

start_date

TIMESTAMP

NULL

end_date

TIMESTAMP

NULL

display_name

VARCHAR(254)

NULL

description

VARCHAR(254)

NULL

long_description

LONG VARCHAR

NULL

parent_cat_id

VARCHAR(40)

NULL

product_type

INTEGER

NULL

Here’s an example of how you could separate the properties in the dcs_product table into four separate multi-value tables to hold locale sensitive content for many different locales:

Table #1: dcs_product

product_id
(primary key)

VARCHAR(40)

NOT NULL

version

INTEGER

NULL

creation_date

TIMESTAMP

NULL

start_date

TIMESTAMP

NULL

end_date

TIMESTAMP

NULL

parent_cat_id

TIMESTAMP

NULL

product_type

VARCHAR(40)

NULL

Table #2: dcs_product_display_name

product_id
(primary key)

VARCHAR(40)

NOT NULL REFERENCES dcs_product(product_id)

locale
(primary key)

VARCHAR(42)

NOT NULL

display_name

VARCHAR(254)

NULL

Table #3: dcs_product_description

product_id
(primary key)

VARCHAR(40)

NOT NULL REFERENCES dcs_product(product_id)

locale
(primary key)

VARCHAR(42)

NOT NULL

description

VARCHAR(254)

NULL

Table #4: dcs_product_long_description

product_id
(primary key)

VARCHAR(40)

NOT NULL REFERENCES dcs_product(product_id)

locale
(primary key)

VARCHAR(42)

NOT NULL

long_description

LONG VARCHAR

NULL

You’ll also have to modify your productCatalog.xml file to refer to these new tables. Here’s an example of a very simple productCatalog.xml file that maps this schema:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE gsa-template
        PUBLIC "-//Art Technology Group, Inc.//DTD General SQL Adapter//EN"
        "http://www.atg.com/dtds/gsa/gsa_1.0.dtd">

<gsa-template>

  <item-descriptor name="product" display-name-resource="itemDescriptorProduct">

    <table name="dcs_product" type="primary" id-column-name="product_id">
      <property category-resource="categoryInfo" name="version" data-type="int"
        column-name="version"/>
      <property category-resource="categoryInfo" name="creationDate" data-
        type="timestamp" column-name="creation_date"></property>
      <property category-resource="categoryBasics" name="startDate" data-
        type="timestamp" column-name="start_date" display-name-
        resource="startDate" required="false"> </property>
      <property category-resource="categoryBasics" name="endDate" data-
        type="timestamp" column-name="end_date" display-name-resource="endDate"
        required="false"> </property>
      <property category-resource="categoryCategorizationAndRelatedProducts"
        name="parentCategory" item-type="category" column-name="parent_cat_id"
        display-name-resource="parentCategory" required="false"> </property>
      <property name="type" data-type="enumerated" column-name="product_type"/>
      </property>
    </table>

    <table name="dcs_product_display_name" type="multi"
      id-column-name="product_id"> multi-column-name="locale">
      <property category-resource="categoryBasics" name="displayName"
                data-type="map" component-data-type="string"
                column-name="display_name" required="true"
                display-name-resource="name">
      </property>
    </table>

    <table name="dcs_product_description" type="multi"
      id-column-name="product_id"> multi-column-name="locale"
      <property category-resource="categoryPresentation" name="description"
                data-type="map" component-data-type="string"
                column-name="description" required="false"
                display-name-resource="description">
      </property>
    </table>

    <table name="dcs_product_long_description" type="multi"
      id-column-name="product_id">
      <property category-resource="categoryPresentation" name="longDescription"
                data-type="map" component-data-type="big string"
                column-name="long_description" required="false"
                display-name-resource="longDescription">
      </property>
    </table>

  </item-descriptor>
</gsa-template>
 
loading table of contents...