[opencms-dev] Locale on-the-fly

Y. Glebov yglebov at eclipse-sp.com
Tue Aug 15 15:42:50 CEST 2006


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/0022099e/attachment.htm>


More information about the opencms-dev mailing list