< Day Day Up > |
If the entirety of your JSP requires translation, you may find programmatically accessing resource bundles impractical . In practice, you will find that help JSPs, for example, contain little or no code and as such can be completely translated without incurring the runtime expense of NLS enablement. WebSphere Portal facilitates this approach by allowing you to organize translated files in a predictable directory structure. Portal will then take responsibility for locating the correct file at runtime. This facility is also available for multiple markup support. Your directory structure should reflect Figure 8-9 on page 259. Figure 8-9. NLS directory structure
Each locale you support must have its own folder and contain whatever fully translated resources you want the portal to serve. If the portal cannot find the requested resource in the appropriate directory, it will attempt to locate the default by searching one level higher. If no default resource is located up the directory tree, an exception is thrown. To retrieve the translated resource, simply use the include method of the PortletContext object. Do not specify the NLS directory structure. This code is illustrated in Example 8-9. You should notice that there is in fact nothing unique about calling a translated JSP and calling the simple JSPs. All the work is done by the portal. Example 8-7. Including translated JSP filesgetPortletConfig().getContext().include("/messagereceiver/jsp/MessageReceiverVi ew.jsp", request, response); |
< Day Day Up > |