TWiki
>
WebXEO Web
>
XeoPrimerXeoXwc
>
XeoPrimerInternationalizationXWC
(revision 6) (raw view)
Edit
Attach
Tags:
tag this topic
create new tag
,
view all tags
-- Main.PedroRio - 18 Jun 2010 ---+ Internationalization (i18N) To create and use multi-language messages in XWC Components and in XVW viewers the following must be made. Steps: _1) Create an Interface/Class with a set of N public static final fields, which return an instance of XUILocalizedMessage and give each of them a name, like in the following example (the example assumes a ViewerMessages Interface)_ <verbatim>public static final XUILocalizedMessage BUILDER_ELAPSED_TIME = new XUILocalizedMessage( ViewersMessages.class.getName(), "TIME_BUILDER" ); public static final XUILocalizedMessage BUILDER_PROCESSING = new XUILocalizedMessage( ViewersMessages.class.getName(), "BUILDER_MESSAGE" ); </verbatim> When creating a new XUILocalizedMessage, two parameters must be passed, the *first is the name of the current class* and the *second, an identifier for the message* _2) Create a ViewerMessages.properties file (the name of the properties file, must match the name of the class/interface) and write the translations for messages in the default application language, for the above example it would be something like:_ <verbatim>TIME_BUILDER = Time that will take to build BUILDER_MESSAGE = Builder is processing</verbatim> <literal> </literal> 3 ) For each of the available languages in your application create _ViewerMessages_pt.properties_, _ViewerMessages_es.properties_, <em>ViewerMessages_XX.properties </em>files so that the translations for other languages are available. The <em>ViewerMessages_pt.properties </em>would be something like the following. <verbatim>TIME_BUILDER = Tempo para terminar o build BUILDER_MESSAGE = Builder está a processar</verbatim> __Usage in a XWC Component__ When developing a custom component, textual content may need to be printed. Instead of making something like this: <verbatim>StringBuffer b = new StringBuffer(); b.append(" Builder is processing "); // processing</verbatim> One can use the already defined messages with the following code: <verbatim>StringBuffer b = new StringBuffer(); b.append(ViewerMessages.BUILDER_ELAPSED_TIME.toString());</verbatim> __Usage in a XVW Viewer__ To use localization in a XVW Viewer an additional step must be performed. In the XML definition of the viewer in the xvw:viewer element the localizationClass attribute must be filled with the fully qualified name of a class which defines the messages (like ViewerMessages in the above example) <verbatim><xvw:viewer beanClass="" beanId="viewBean" localizationClasses='pt.itds.project.localization.ViewerMessages> </xvw:viewer></verbatim> And, to use a message in a Menu component, one would declare the component as <verbatim><xvw:menu text='@{BUILDER_ELAPSED_TIME}'/></verbatim> To continue
Edit
|
Attach
|
P
rint version
|
H
istory
:
r7
<
r6
<
r5
<
r4
<
r3
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r6 - 2011-03-31
-
PedroRio
WebXEO
XEO Primer
-
Instalation
-
Introduction
-
Concepts
-
Architecture
-
XEO Library
-
Deploy to EAR
-
PreferenceStore
XEO - Core
-
XEO Model Reference
-
Security
-
Java API
-
BOL
-
XEOQL (BOQL)
-
Administrating
-
Background Tasks
-
boConfig.xml
-
Web.xml
-
Known Issues
-
XEO Flags
XEO - XWC
- Web Components
- Java Samples
- Custom Components
- Component Plugins
- Internationalization
- Viewer Events
- Value Change Listeners
- XUIServlet
- XeoLocalization
- XvwTemplates
Create New Topic
WebXEO Web
No permission to view
TWiki.WebTopBar
No permission to view
TWiki.WebBottomBar