Tapestry is designed to make the web application localization easy and
offers the ability to define different localized templates for the same component.
For example, Home.html
would be the default template of the Home page, however
Home_fr.html
would be used in all French locales, while Home_zh_CN.html
would be used in
China and Home_zh_TW.html
would be used in Taiwan.
Web developers and designers in different countries tend to use different character sets for the templates they produce. English, German, French templates are typically produced in ISO-8859-1, Russian templates often use KOI8-R, and Chinese texts are normally written in Big5. Tapestry allows the application to configure the character set used in its templates and makes it possible to use different character sets for templates associated with different components and different locales.
The character set of a template is defined using the
org.apache.tapestry.template-encoding
configuration property. The search path of this property is slightly different then the
standard one and allows specific components to use other character sets:
As a <property>
of the <page-specification>
or the <component-specification>
(in the page or component specification).
This configuration will apply only to the page or component where it is defined.
As a <property>
of the <library-specification>
(in the library specification, if the components are included in a library).
This configuration will apply to all pages and components in the library.
As a <property>
of the <application>
(in the application specification,
if the application uses one).
As an <init-parameter>
for the servlet, in the web application deployment descriptor.
As an <init-parameter>
for the servlet context, also in the web application deployment descriptor.
As a JVM system property.
The hard-coded default "ISO-8859-1".
Tapestry also makes it possible to define the character set used by the templates specific
to a particular locale by appending the locale to the property name above.
As an example, the
org.apache.tapestry.template-encoding_ru
configuration property would define
the character set used by the Russian templates, such as Home_ru.html
.
This allows templates for different locales to use different character sets,
even though they are in the same application.
For example, it is possible for all Russian templates in the application to use the KOI8-R
character set and all Chinese templates to use Big5 at the same time.
The character sets used by the templates do not reflect in any way on the character set
Tapestry uses to encode its response to the browser. The character sets are used when reading
the template to translate it appropriately into Unicode.
The output character set is defined by the
org.apache.tapestry.output-encoding
configuration property.