0

如何在 actions.xml 中使用/翻译 (url_expr/available_expr)?

我通常的方法是为每种语言制作一个单独的“对象”:

<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>
4

1 回答 1

1

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.

于 2013-05-06T17:34:34.367 回答