How to translate i18n Plone actions.xml - internationalization

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>

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.

Related

Add entry to dictionary in child object

How is it possible to add entry to dictionary, defined in parent object, from the child object?
*UPDATED
I edit my config as follows:
<object id="ParentType" singleton="false" type="SomeType">
<property name="FieldNameMap">
<dictionary key-type="string" value-type="string" >
<entry key="Title" value="TitleName"/>
</dictionary>
</property>
</object>
<object id="ChildType" singleton="false" type="SomeType" parent="ParentType">
<property name="FieldNameMap">
<dictionary merge="true">
<!-- this entry should be added to, not replace the whole Dictionary -->
<entry key="Position" value="PositionName"/>
</dictionary>
</property>
</object>
but, unfortunately, it now throws cast exception:
Cannot convert property value of type
[System.Collections.Specialized.HybridDictionary] to required type
[System.Collections.Generic.IDictionary`2[[System.String,
],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]]
I haven't tried this myself, but according to the docs, spring.net will use the Add method of the collection to add items, if the collection itself is exposed as a readonly property.
So it might be possible to use object definition inheritance to achieve the behavior you describe. Config will be something like:
<object id="ParentType" singleton="false" type="SomeType"
abstract="true">
<property name="FieldNameMap">
<dictionary>
<entry key="Title" value="TitleName"/>
</dictionary>
</property>
</object>
<object id="ChildType" singleton="false" type="SomeType"
parent="ParentType">
<property name="FieldNameMap">
<dictionary>
<!-- this entry should be added to, not replace the whole Dictionary -->
<entry key="Position" value="PositionName"/>
</dictionary>
</property>
</object>
This will only work if FieldNameMap is a readonly property.

How We Can Break a String in Wso2esb using Xpath

I wish to break a string in wso2esb using xpath
my input like this
<property name="Message" value="assetname:ups,assetcode:452chi,assetid:548935,assetvalue:215" scope="default"/>
i need break in same property using xpath
i need like this
assetname:ups
assetcode=452chi
assetid=54895
assetvalue=215
for this i tried with tokenize function but wso2esb showing errors
my configure file
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Xpathcheck" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="max" value="1" scope="default" type="STRING"/>
<property name="min" value="1" scope="default" type="STRING"/>
<property name="MessageText" expression="fn:concat('Assetid:',get-property('min'),',','Assetname:',get-property('max'))" scope="default" type="STRING"/>
<property name="Tokenize" expression="fn:tokenize(get-property('Messagetext'),',')" scope="default" type="STRING"/>
<log>
<property name="MessageText" expression="get-property('MessageText')"/>
<property name="Tokenize" expression="get-property('Tokenize')"/>
</log>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
But its throwing errors like this u have any idea for this i need store this in Db table as a one field which look like separate lines
error is
ERROR - SynapseXPath Evaluation of the XPath expression fn:tokenize(get-property('Messagetext'),',') resulted in an error
org.jaxen.UnresolvableException: No Such Function tokenize
tokenize is a function comes with XPath 2.0. To enable XPath 2.0 functions uncomment the following entry in the synapse.properties file which is located at $ESB_HOME/repository/conf directory
synapse.xpath.dom.failover.enabled=true
then you have to specify the mediator as follows,
<property name="Message" value="a,b,c,d,e" scope="default"/>
<property xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Tokenize" expression="fn:tokenize(syn:get-property('Message'),',')" scope="default" type="STRING"/>
I dont think this can be done through XPath, XPath is to navigate elements in an XML. You can do this by using a script mediator and write a JS to break the property values.
use the following to access the ESB params from the script mediator
<script language="js"> var test_param = mc.getProperty('Message')
Use the following to retrieve the params within the script mediator back to the ESB
mc.setProperty("param1",var1)
mc.setProperty("param2",var2)
Use the javascript to carry out the required string manupulations

Including dynamic images in a PDF with BIRT

I am trying to use BIRT 2.5.0 to generate a pdf file. BIRT is called from pHp (this is done thanks to JavaBridge and a Tomcat server).
And I am simply trying to create a checkbox, checked under certain conditions.
I looked a bit on the internet and found 2 different ways to do it.
The first way is to play with the Visibility if the field "idclassebillet" (on which I am making the test) has a value of 1. I did it this way :
<image id="9010">
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">row["classEq1"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"] == 1</expression>
<property name="dataType">boolean</property>
</structure>
</list-property>
<property name="source">embed</property>
<property name="imageName">checkbox_unchecked.png</property>
</image>
But this doesn't work.
So the second solution that I found was to play with a simple URL. This solution is much more convenient, but doesn't work neither. This would looks like that.
<image id="9018">
<property name="source">url</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<expression name="uri" type="javascript">
if(row["classEq1"] == 1)
"http://my.server.com/checkbox_checked.png"+row["classEq1"];
else
"http://my.server.com/checkbox_unchecked.png"+row["classEq1"];
</expression>
</image>
In both cases, I declare the field "dataSetRow["idfield"]" like that :
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="infoBordereau" id="178">
<structure name="cachedMetaData">
<list-property name="resultSet">
...
<structure>
<property name="position">9</property>
<property name="name">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</structure>
<property name="dataSource">GestionBillet</property>
<list-property name="resultSet">
...
<structure>
<property name="position">8</property>
<property name="name">idclassebillet</property>
<property name="nativeName">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</list-property>
....
</oda-data-set>
</data-sets>
I checked that I can access to the content of "idclassebillet". If I simply print it this way, it works fine :
<data id="90060001">
<property name="whiteSpace">nowrap</property>
<property name="dataSet">infoBordereau</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<property name="resultSetColumn">classEq1</property>
</data>
And whatever the solution I choose to get my "dynamic" images, I always get the same image, whatever the value of "dataSetRow["idclassebillet"]" is.
I have no problem accessing and printing the image. The problem is more to "test" the value of the "idclassebillet" field (ie. how can I access this field ?).
I hope that you understand what I am trying to do. If you have a better solution (and if possible an example of working code), don't hesitate to share ^^ :)
Many thanks,
Raphaƫl POITTEVIN
NB : At first, I wanted my images to be embedded in the document (this what I use in the first solution), but as this didn't worked, I used an images hosted on http://my.server.com ...
If your objective is to display an unchecked/checked checkbox, have you considered using the Wingdings font with characters 0xA8 and 0xFD or 0xFE?

XDT Config Transforms - ReplaceAll?

I've got a custom section in my web.config file similar to this structure:
<Messages>
<Message id="1'>
<Property Name="foo" value="bar" />
</Message>
<Message id="2'>
<Property Name="foo" value="bar2" />
</Message>
</Messages>
I want to apply a custom transformation on this such that I can change the value of ALL instances of the Property element with Name="foo" - but I cant seem to get it to work.
I've tried:
<Messages>
<Message>
<Property Name="foo" value="updated" xdt:Locator=Match(Name) xdt:Transform="Replace" />
</Message>
</Mesasges>
I can remove all the elements by replacing the Transform=Replace with a Transform=RemoveAll - any ideas how I can achieve something similar to replace all the values?
It seems like Transform:Replace only replaces the first matched element from the documentation on msdn: ...If more than one element is selected, only the first selected element is replaced. I solved this issue by using a combination of Match-Conditions and SetAttributes, something like:
<Messages>
<Message>
<Property value="updated" xdt:Locator=Condition(#Name='foo') xdt:Transform="SetAttributes(value)" />
</Message>
</Messages>

Problem with evaluating XPath while using Apache Synapse

I'm trying to run Apache Synapse samples on ubuntu 11.04 64-bit and I have found problem with evaluating XPath expression in sample nr 2.
My XPath expression:
$ <definitions xmlns="http://ws.apache.org/ns/synapse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd">
<sequence name="main">
<switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples">
<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
<case regex="MSFT">
<property name="symbol" value="Are you sure? - MSFT"/>
</case>
<default>
<!-- it is possible to assign the result of an XPath expression as well -->
<property name="symbol" expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"/>
</default>
</switch>
<log level="custom">
<!-- the get-property() XPath extension function allows the lookup of local message properties
as well as properties from the Axis2 or Transport contexts (i.e. transport headers) -->
<property name="symbol" expression="get-property('symbol')"/>
<!-- the get-property() function supports the implicit message headers To/From/Action/FaultTo/ReplyTo -->
<property name="epr" expression="get-property('To')"/>
</log>
<!-- Send the messages where they are destined to (i.e. the 'To' EPR of the message) -->
<send/>
</sequence>
It is run on following data:
$ <soapenv:Body><m0:getQuote xmlns:m0="http://services.samples"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote></soapenv:Body></soapenv:Envelope>
And result is:
2011-08-08 15:37:04,227 [-] [HttpClientWorker-1] DEBUG SwitchMediator XPath : //m0:getQuote/m0:request/m0:symbol evaluates to :
2011-08-08 15:37:04,227 [-] [HttpClientWorker-1] DEBUG SwitchMediator None of the switch cases matched - executing default
while it should go to:
$<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
Does anyone knows what can be the problem? I have installed that ubuntu few days ago, so there is possibility, that there is something missing on that system.
Try with full xpath..
<switch xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m0="http://services.samples" source="//soapenv:Envelope/soapenv:Body/m0:getQuote/m0:request/m0:symbol">

Resources