user966660
user966660

Reputation: 592

How to translate i18n Plone actions.xml

How can I use/translate the (url_expr/available_expr) in actions.xml?

My usual way was to make a seperate "object" for each language:

<object name="contact" meta_type="CMF Action" i18n:domain="my.theme">
 <property name="title" i18n:translate="">Contact</property>
 <property name="description" i18n:translate=""></property>
 <property
  name="url_expr">string:${globals_view/navigationRootUrl}/contact</property>
 <property name="icon_expr"></property>
 <property name="available_expr">python:request.LANGUAGE == 'en'</property>
</object>

<object name="contact-de" meta_type="CMF Action" i18n:domain="my.theme">
 <property name="title" i18n:translate="">Contact</property>
 <property name="description" i18n:translate=""></property>
 <property
  name="url_expr">string:${globals_view/navigationRootUrl}/kontakt</property>
 <property name="icon_expr"></property>
 <property name="available_expr">python:request.LANGUAGE == 'de'</property>
</object>

Upvotes: 0

Views: 205

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1122152

If your contact / kontakt content is multilingual content managed by LinguaPlone, you can use the takeaction add-on to create one action that'll switch between translations as needed.

takeaction has it's own configuration file, like actions.xml it is a Generic Setup file:

<?xml version="1.0"?>
<object name="portal_takeaction"
   meta_type="TakeAction content-as-actions tool">
  <item category="site_actions" path="en/contact" />
</object>

The above configuration designates a content object at en/contact as a site_actions action item. It'll be listed in that action category, taking the title and description of one of the translations of the content object matching the current language.

You do not list the action in actions.xml anymore; the takeaction tool is itself a action provider.

Disclaimer: I am the original author of takeaction.

Upvotes: 1

Related Questions