[opencms-dev] Locale macro in XSD schema

Christoph Fröhlich cfauto at folge2.de
Sat Feb 16 16:44:14 CET 2013


HI Arturo,

maybe you can create a custom widget by subclassing
  org.opencms.widgets.CmsCategoryWidget


In the method
  getStartingCategory(CmsObject, String)

you have access to the current locale. I think this should enable you to construct locale dependent starting categories.

Regards 
Christoph

Am 15.02.2013 um 17:51 schrieb Rüdiger Kurz <r.kurz at alkacon.com>:

> Hi,
> 
> OK, enable the content managers to create categories and localize the display values is an argument. Anyway it would be better using the same taxonomy.
> 
> If you have only two locales an 'ugly' workaround would be using two properties: simple and straight, but technical not clean. So why don't create an 'config' XSD that has multiple nested elements holding a category together with its display name. This will make it easy to edit the localized display values in a comfortable way for content managers and it would be technically clean.
> 
> You could initialize this content with a Java Bean or what ever you need to make access easier than writing scriplet code.
> 
> @Tobias, sorry but your mail comes in while I've already used the word 'ugly', anyway the property variant is simple and straight.
> 
> regards
> Rüdiger
> 
> 
> Am 15.02.2013 17:18, schrieb Arturo Martín Lladó:
>> Hi, Rüdiger.
>> 
>> I can say it's a very original solution :-)
>> 
>> Unfortunately, the categories should be administrated (and localized,
>> they are siblings with different Title property) by the final users,
>> and the edition of a Java properties file it's not a solution suitable
>> for them.
>> 
>> That's why we have a categories taxonomy like this:
>> 
>> =====
>> /_categories
>>     ca
>>         categories with locale "ca" configured as property by the parent
>>         [...]
>>     es
>>         categories with locale "es" configured as property by the parent
>>         [...]
>> =====
>> 
>> and that's why we'd like to offer to the final user a default category
>> pointed using de "configuration" attribute of the CategoryWidget.
>> 
>> Thank you anyway, Rüdiger. I really appreciate your help and any other
>> tip about this problem will be very welcome.
>> 
>> I guess that support for macros processing on the "configuration"
>> attribute of the layout widgets could be part of the wishlist of the
>> next release of OpenCms :-)
>> 
>> Again, thanks for your help and have a nice weekend.
>> 
>> Regards.
>> 
>> 2013/2/15 Rüdiger Kurz <r.kurz at alkacon.com>:
>>> Hi,
>>> 
>>> think you are right with your assumption. What you're trying to archive is
>>> localization of categories. I might be wrong, but I think that localizing
>>> categories,tags,facets,... does not make that much sense, since the 'tags'
>>> should be the same for one content. (Categories are assigned to VFS
>>> resources not to the real-localized content).
>>> 
>>> However, I would try to use the same taxonomy for all languages and then
>>> localize its output at rendering time: The messages.properties could have
>>> entries per category path, using dots instead slashes and then on JSP side
>>> you will replace the slashes pf the category path with dotes and try then to
>>> receive the localized value.
>>> 
>>> What do you think?
>>> 
>>> Am 15.02.2013 16:49, schrieb Arturo Martín Lladó:
>>> 
>>>> Hi, Rüdiger.
>>>> 
>>>> I tried with this:
>>>> 
>>>>             <resourcebundles>
>>>>                  <xmlbundle name="element.workplace.xml">
>>>>                      <bundle locale="ca">
>>>>                          <resource
>>>> key="package.element.language">ca</resource>
>>>>                      </bundle>
>>>>                      <bundle locale="es">
>>>>                          <resource
>>>> key="package.element.language">es</resource>
>>>>                      </bundle>
>>>>                  </xmlbundle>
>>>>              </resourcebundles>
>>>> 
>>>> The value stored in %(key.package.element.language) is displayed OK in
>>>> the default values of OpenCmsString fields, but it seems to be ignored
>>>> in the attribute "configuration" of a CategoryWidget.
>>>> 
>>>> Is this the expected behaviour? Maybe macros are not processed in
>>>> <layout> elements?
>>>> 
>>>> Kind regards.
>>>> 
>>>> 2013/2/15 Rüdiger Kurz <r.kurz at alkacon.com>:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> it's me again. You can access localized message bundles with:
>>>>> %(key.your.label)
>>>>> 
>>>>> imagine a XSD:
>>>>> 
>>>>> <resourcebundle name="your.package.workplace"/>
>>>>> [...]
>>>>> <layout element="Elem"
>>>>>          widget="CategoryWidget"
>>>>>          configuration="... %(key.language) ..." />
>>>>> 
>>>>> and a workplace_en.properties
>>>>> containing:
>>>>> language=en
>>>>> 
>>>>> and a workplace_de.properties
>>>>> containing:
>>>>> language=de
>>>>> 
>>>>> This should do the trick.
>>>>> 
>>>>> regards
>>>>> Rüdiger
>>>>> 
>>>>> 
>>>>> Am 15.02.2013 14:39, schrieb Rüdiger Kurz:
>>>>> 
>>>>>> sorry not quiet sure if this works inside the XSD, but inside the
>>>>>> content editor you can use it.
>>>>>> 
>>>>>> Am 15.02.2013 14:37, schrieb Rüdiger Kurz:
>>>>>>> 
>>>>>>> 
>>>>>>> yes, %(request.locale)
>>>>>>> 
>>>>>>> Am 15.02.2013 14:27, schrieb Arturo Martín Lladó:
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Hi, list.
>>>>>>>> 
>>>>>>>> Is there available any locale macro for using it in XSD schemas?
>>>>>>>> 
>>>>>>>> I'd like to do something like this:
>>>>>>>> 
>>>>>>>>      <layouts>
>>>>>>>>                   [...]
>>>>>>>>                   <layout element="Categoria" widget="CategoryWidget"
>>>>>>>> 
>>>>>>>> 
>>>>>>>> configuration="category=/_categories/__LOCALE_MACRO___/tipoDocumento/|onlyleafs=true"/>
>>>>>>>> 
>>>>>>>> 
>>>>>>>>      </layouts>
>>>>>>>> 
>>>>>>>> This is because our categories tree is organized this way:
>>>>>>>> /sites/default/_categories/__LOCALE__/...
>>>>>>>> 
>>>>>>>> Kind regards.
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
> 
> -- 
> Rüdiger Kurz
> 
> -------------------
> 
> Alkacon Software GmbH - The OpenCms Experts
> Rüdiger Kurz
> An der Wachsfabrik 13
> 50996 Koeln, DE
> 
> Tel: +49 (0)2236 3826-16
> Fax: +49 (0)2236 3826-20
> Email: r.kurz at alkacon.com
> 
> http://www.alkacon.com
> http://www.opencms.org
> 
> Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 54613
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
> 
> 






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


More information about the opencms-dev mailing list