This release of the Java Pet Store can be localized in Japanese. While
the Japanese localization is not complete, the application is
internationalized, and lacks only some content translation.
The architecture fully supports content localization.
Installing Japanese Database Tables
In order to run the
Japanese Petstore you will need to load the Japanese tables into the
Cloudscape database by running the populate script. (Note that this
only works for the Cloudscape database. Other databases are not
supported in Japanese for this release.)
- Change directories to
jps1.1/database.sql
- On Unix, run:
populate
On Windows, run: populate.bat
This will create the database tables and populate them with data.
- To see the japanese version of the petstore, follow the
instructions in the main
index.html
file and click on Enter the Japanese store on the first
page of the application.
Adding Localized Content
If you want to localize the Pet Store, you will need to provide a
screendefinitions.xml file for the target locale. In
this file you can provide the localized information needed to
display content for the locale you plan to support. In the case of
Japanese, the localized content is maintained in the directory
jps1.1/docroot/ja . You may choose to localize the
entire application, or only parts of it. Please follow the these
steps to add or change localized content in the Pet Store.
- Create the localized
screendefinitions.xml file,
and add a mapping to it in the requestmappings.xml
file located in the Pet Store's
jps1.1/src/docroot/xml directory. Add a
language attribute to the
screen-definitions tag. The language
attribute's value is formed of the language and country two-letter
abbreviations separated by a "_". In the case of Japanese the
language is ja and country is JP so the
tag defining the definitions would appear as:
<screen-definition url="/xml/ja/screendefinitions.xml" language="ja_JP"/>
- You will also need to modify the
LanguageHandler
which is located in the
com.sun.j2ee.petstore.control.web.handler package,
setting the locale to the lanaguage you specify when you call
invoke the handler. In the case of the Java Pet Store, the URL for
changing the language is /control/language . To change
to Japanese you will use
/control/language?language=Japanese .
On the web tier, a Locale object is stored as part of the user
session, under the key language . By default, the Pet
Store uses Locale.US . Enabling Japanese localization
changes it to Locale.Japan .
-
You will also need to change the
DatabaseNames file,
located in the
com.sun.j2ee.blueprints.shoppingcart.util directory
of the ShoppingCart Component, to point to the correct database
tables in relation to the current locale. All calls to the catalog
component require a locale as an argument.
|