blob: cae2b9c1eff012393739b5e996274b5619ece714 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<ui:composition template="/main.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
Tobago supports internationalization and localization.
<ul>
<li>Unicode is used internally.</li>
<li>Content in different languages can be provided by resource bundles.</li>
<li>Like content, images and scripts can be localized.</li>
</ul>
<tc:out value="#{demoBundle.not_translated}"/>
<tc:selectOneChoice value="#{localeController.locale}" label="Locale">
<f:selectItems value="#{localeController.localeItems}"/>
<tc:event action="#{localeController.submit}"/>
</tc:selectOneChoice>
<tc:in label="ISO 639 / 3166" value="#{demoBundle.locale_short}" readonly="true"/>
<p>
The localization of JSF works with Java resource bundles.
These bundles needs to be definded in the <code>faces-config.xml</code> under the
section <code>&lt;resource-bundle&gt;</code>.
</p>
<p>
<tc:image value="#{request.contextPath}#{localeController.imageCountryName}">
<tc:style width="100px" height="100px"/>
</tc:image>
</p>
<p>
The image url will be evaluated by the Java Bean <code>LocaleController</code>.
</p>
<tc:tabGroup>
<tc:tab label="Tobago Resource Bundle">
<p>
Tobago comes with a resource bundle
<code>org.apache.myfaces.tobago.context.TobagoResourceBundle</code> mapped to
<code>tobagoResourceBundle</code>.
This bundle contails translated text fragments used by Tobago e. g.
for label of components.
It's easy to expand this bundle to support more languages.
</p>
<p>
The next table shows the keys and the translation with the locale of the current session.
The locale can be changed with the selector above.
</p>
<tc:sheet var="entry" value="#{bundleController.resources}" markup="small">
<tc:style maxHeight="500px"/>
<tc:column label="Key" sortable="true">
<tc:out value="#{entry.key}" labelLayout="skip"/>
</tc:column>
<tc:column label="Value" sortable="true">
<tc:out value="#{entry.value}" labelLayout="skip"/>
</tc:column>
</tc:sheet>
</tc:tab>
<tc:tab label="Tobago Message Bundle">
Tobago comes with a message bundle for Tobago specific (info/warn/error) messages.
<tc:sheet var="entry" value="#{bundleController.messages}" markup="small">
<tc:style maxHeight="500px"/>
<tc:column label="Key" sortable="true">
<tc:out value="#{entry.key}" labelLayout="skip"/>
</tc:column>
<tc:column label="Value" sortable="true">
<tc:out value="#{entry.value}" labelLayout="skip"/>
</tc:column>
</tc:sheet>
</tc:tab>
</tc:tabGroup>
</ui:composition>