felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Internationalization of the Web Console
Date Wed, 27 Jan 2010 14:31:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="http://cwiki.apache.org/confluence/display/FELIX/Internationalization+of+the+Web+Console">Internationalization
of the Web Console</a></h2>
    <h4>Page  <b>added</b> by             <a href="http://cwiki.apache.org/confluence/display/~fmeschbe">Felix
Meschberger</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <div class='panelMacro'><table class='noteMacro'><colgroup><col
width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/warning.gif"
width="16" height="16" align="absmiddle" alt="" border="0"></td><td><p>The
functionality described on this page is not included in a release of the Web Console yet.</p></td></tr></table></div>

<p>Internationalization support of the Web Console is based on Java Resource Bundles
loaded from the plugin bundles and is transparent to the plugin itself. In addition to localization
the mechanism described here can also be used for generic templating of Web Console responses.</p>


<h2><a name="InternationalizationoftheWebConsole-BasicMechanism"></a>Basic
Mechanism</h2>

<p>All requests handled by web console plugins are wrapped by response wrapper, which
installs a Writer filter if the response is a <tt>text/html</tt> response. This
writer filter recognizes variables of the pattern <tt>$&#123;name&#125;</tt>
and tries to replace that part of the output with another string:</p>

<ul>
	<li>If a variable of that name exists, the value of that variable is used. See Variable
Resolution below.</li>
	<li>Otherwise if a resource bundle provides a translated string for the name, that
string is used. See Resource Bundles below.</li>
	<li>Otherwise the name itself is just placed in the output.</li>
</ul>



<h2><a name="InternationalizationoftheWebConsole-VariableResolution"></a>Variable
Resolution</h2>

<p>Variable Resolution is based on a <tt>org.apache.felix.webconsole.VariableResolver</tt>
object provided as a request attribute prior to calling the <tt>ServletResponse.getWriter()</tt>
method. If no such resolver is provided in the request, an instance of the <tt>org.apache.felix.webconsole.DefaultVariableResolver</tt>
is used and stored in the request. Replacing the <tt>VariableResolver</tt> after
the <tt>getWriter()</tt> has been called has no effect for variable resolution.
Variables may be added to the <tt>VariableResolver</tt> even after the <tt>getWriter()</tt>
method has been called.</p>



<h2><a name="InternationalizationoftheWebConsole-ResourceBundles"></a>Resource
Bundles</h2>

<p>Resources for the Resource Bundles is provided by the Web Console bundle on the one
hand and by the bundle providing the plugin on the other hand. Resources are identified inside
a bundle with the <tt>Bundle-Localization</tt> manifest header as described in
Section 3.10 Localization in the Core Specification.</p>

<p>This also means, that additional translations may be provided by fragment bundles.</p>

<p>During request processing the <tt>Locale</tt> of the request (<tt>ServletRequest.getLocale()</tt>)
is used to identify the actual resources to use. From this information a <tt>ResourceBundle</tt>
is constructed from a collection of the resources provided by the plugin bundle and the resources
provided by the Web Console.</p>


<h3><a name="InternationalizationoftheWebConsole-WebConsoleLocalization"></a>Web
Console Localization</h3>

<p>The Web Console contains a single localization file <tt>OSGI-INF/l10n/bundle.properties</tt>.
Fragments attached to the Web Console bundle may provide translations for these resources.
All plugins of the Web Console itself will use a ReosurceBundle, which is only based on the
localization of the Web Console itself.</p>



<h2><a name="InternationalizationoftheWebConsole-UsingTemplating"></a>Using
Templating</h2>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Internationalization+of+the+Web+Console">View
Online</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Internationalization+of+the+Web+Console?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message