[opencms-dev] Locale on-the-fly

Jonathan Woods jonathan.woods at scintillance.com
Tue Aug 15 19:27:06 CEST 2006


Cool.
 
You'll find OpenCms Javadoc useful here, particularly for I_CmsXmlDocument:
 
    /**
     * Returns a List of all locales that have at last one element in 
     * this XML document.<p>
     * 
     * @return a List of all locales that have at last one element in this
XML document
     */
    List getLocales();
 
    /**
     * Returns a List of all locales that have the given element set in this
XML document.<p>
     * 
     * If no locale for the given element name is available, an empty list
is returned.<p>
     * 
     * @param element the element to look up the locale List for
     * @return a List of all Locales that have the given element set in this
XML document
     */
    List getLocales(String element);
 
If you're not using an IDE, you can still see the Javadoc at various places
on the web; just Google for e.g. "opencms javadoc" (but make sure you're
getting the documentation for a recent version).
 
Jon

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Y. Glebov
Sent: 15 August 2006 14:43
To: 'The OpenCms mailing list'
Subject: RE: [opencms-dev] Locale on-the-fly



Thanks, works great.

 

I also found a CmsJspXmlContentBean that can extract elements using
specified language.
 
Yuriy.
 
P.S. Do you know how to detect locales that present in file?

 

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jonathan Woods
Sent: Tuesday, August 15, 2006 1:40 PM
To: 'The OpenCms mailing list'
Subject: RE: [opencms-dev] Locale on-the-fly

 

Yuriy -

 

I use Java rather than the OpenCms taglib, and in theory that makes things
quite easy.  Maybe this would be useful for you too.

 

For example, CmsJspActionElement provides a convenience method
getContent(String target, String element, Locale locale) which returns the
String contents of an element with xpath 'element' in resource with
site-relative path 'target'.  The value of locale in this case is a Locale
derived from language, rather than a country-specific one, since under the
hood OpenCms deals mainly with languages - so you'd pass in Locale.ENGLISH,
Locale.GERMAN etc, rather than Locale.UK etc.

 

If you're retrieving the contents of several XML elements, then it's more
efficient to get hold of an instance of the OpenCms interface
I_CmsXmlDocument.   Again, the Java API makes this fairly easy.  To use an
example from the source code of CmsJspActionElement itself:

final CmsResource cmsResource =
this.cmsObject.readResource(relativeResourcePath, CmsResourceFilter.ALL);
final CmsFile resourceFile = CmsFile.upgrade(cmsResource, this.cmsObject);
final CmsXmlContent xmlDocument =
CmsXmlContentFactory.unmarshal(this.cmsObject, resourceFile, true);

Jon

 

 

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Y. Glebov
Sent: 15 August 2006 09:34
To: opencms-dev at opencms.org
Subject: [opencms-dev] Locale on-the-fly

Hi all.

 

My problem with including page element in another locale is still actual.

I have a page with content and I need to switch languages only for this

Content, but language of other page elements must remain the same. 

How it's possible?

 

Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060815/e0f55187/attachment.htm>


More information about the opencms-dev mailing list