Someone asked me a question about "velocity decorators and localization". I responded back directly, but I thought it might also be useful to have the response on the Jetspeed User list as well.
...

In your decorator you can access quite a lot of localized current page information with calls like:

$element.getTitle($preferedLocale)

Above we are retrieving a title from a menu. All of the folder and page model is localized. We have had requests to use resource ids instead of storing the localization in the page or folder.
Here is an example of localizing the title of a page:

  <metadata name="title" xml:lang="fr">Bienvenue a Jetspeed</metadata>
<metadata name="title" xml:lang="ja">Jetspeed 2 へようこそ</ metadata> <metadata name="title" xml:lang="es">ÁBienvenido a Jetspeed 2!</ metadata> <metadata name="title" xml:lang="hu">Kšszšnti a Jetspeed 2!</ metadata> <metadata name="title" xml:lang="zh">欢迎来到Jetspeed 2</ metadata> <metadata name="title" xml:lang="zh-TW">歡迎來到Jetspeed 2</ metadata> <metadata name="title" xml:lang="ko">Jetspeed 2 에 오신 것을 환 영합니다</metadata>

Note that $preferedLocale is made available to you in any decorator, see jetspeed_macros.vm:

  #set($preferedLocale = $JS2RequestContext.locale)

You can find out more about PSML (the portlet structured markup language), here:

http://portals.apache.org/jetspeed-2/guides/guide-psml.html
http://portals.apache.org/jetspeed-2/guides/guide-menus-declarative-psml.html

You can also localize the location of psml pages using the profiler with control directories and two letter language codes. This is useful if you have completely different layout based on language:

http://portals.apache.org/jetspeed-2/guides/guide-profiler.html

You can also localize the location of images by making subdirectories in your decorator based on the two letter language code:

<div id="Logo" style="float:left;"><img src='#GetPageResource("images/ ${preferedLocale.Language}/logo.gif")'></div>

Finally, if you want to associate a resource file with a decorator, there are some calls available to you on the Decoration interface:

  /**
     * @return the resource bundle locator prefix.
     */
    String getResourceBundleName();

    /**
* @return the resource bundle for the given Locale and RequestContext.
     */
ResourceBundle getResourceBundle( Locale locale, org.apache.jetspeed.request.RequestContext context );

So say in your layout decorator, add this line:

<b>$rootFragment.decoration.getResourceBundle($preferedLocale, $ JS2RequestContext ).getString("desktop.pageeditor.dialog.labels.deletepage")</b>

and it should print (for the tigris layout decorator):

"Are you sure you want to delete this page?"

So you can add resources to the decorator under the resources/ Messages_(XX).properties

where XX is the language code such as "en" or "fr" or "de"


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to