Magento: how to translate action tag content? - magento-1.5

I have default page.xml.
I have added
<block type="core/text" name="for_everyone">
<action method="setText" translate="text"><text>Some text!</text></action>
</block>
to
<block type="core/text_list" name="content" as="content" translate="label">
<label>Main Content Area</label>
</block>
and I got this one:
<block type="core/text_list" name="content" as="content" translate="label">
<label>Main Content Area</label>
<block type="core/text" name="for_everyone">
<action method="setText" translate="text"><title>Some text!</title></action>
</block>
</block>
Then I added two files for my theme:
app/design/frontend/default/default/locale/en_US/translate.csv
"Some text!","Some text!"
and
app/design/frontend/default/default/locale/fr_FR/translate.csv
"Some text!","un text!"
But every time I run any language I see "Some text!". At the same time selected lang for website is used correct. For example the string from catalog.xml translates perfect:
<block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml">
<action method="setImgSrc"><src>images/media/col_right_callout.jpg</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>Keep your eyes open for our special Back to School items and save A LOT!</alt></action>
</block>
I also tried to use smth like that and other tags:
<action method="setText" translate="title"><text>Some text!</title></action>
Does anybody know what the problem is?

The translate attribute should contain a space-delimited list of tag names to translate. For example, if the argument one is passing to Mage_Core_Block_Text::setText() is encapsulated in ` node, you should have the following:
<action method="setText" translate="foo"><foo>Some text!</foo></action>
Unless one is trying to pass in an array structure via layout XML, argument node names do not matter.
Also worth noting is that if one sets the module attribute, that string will be passed to the helper class factory method (Mage::helper() - see timeline below). For instances where incorrect translation is being seen, verify that there are no overriding entries in the core_translate database table, which would only be entered if inline translation has been used.
Call sequence:
Mage_Core_Controller_Varien_Action::loadLayout()
::generateLayoutBlocks()
Mage_Core_Model_Layout::generateBlocks()
::_generateBlocks()
::_generateAction()
::_translateLayoutNode()
It is _translateLayoutNode() which processes the translate attributes of the <action /> directives:
if (isset($node['module'])) {
$args[$arg] = Mage::helper((string)$node['module'])->__($args[$arg]);
}
else {
$args[$arg] = Mage::helper('core')->__($args[$arg]);
}

Check the name of your locale folder (trailing e)
app/design/frontend/default/default/local/en_US/translate.csv
app/design/frontend/default/default/locale/en_US/translate.csv

Related

find xml-nodes by tag with wildcard

I am trying to find any nodes in a xml whos tags start with a certain pattern.
<data>
<general>
<va value="400" /> <!--looking for this "v-tag"-->
<vb value="42" /> <!-- and this one-->
<y value="43" />
</general>
<special>
<va value="100" />
</special>
</data>
I cannot put together the xpath expression. Something like this
xyz = lxml.etree.parse( ... )
vees = xyz.xpath("general/[tag='v*']")
I would like to have vees beeing
vees
Out[64]: [<Element va at 0x....>, <Element vb at 0x...>]
Try changing:
vees = xyz.xpath("general/[tag='v*']")
to
doc.xpath('//general//*[starts-with(name(),"v")]')
and see if it works.

Open password protected Excel spreadsheet with UiPath

I was wondering if anyone had succeeded in opening a password protected XL spreadsheet with UiPath.
I tried using "Open Workbook" and entering the password in password field ... but that didn't work.
I tried using Open Application ... but I can't seem to talk to the password dialogue box.
Really flumoxed !
Update the Excel Activities. Use the new Excel Application Scope. Set the password property.
Try saving this password-protected Excel dummy data file (https://cdn-business2.discourse.org/uploads/uipath/original/2X/2/25c38fb93744b863e5db1e50f757a6cdf8b77128.xlsx) and run it against this code below (save as XAML, the UiPath file).
Hope that helps.
<Activity mc:Ignorable="sap sap2010 sads" x:Class="excel_password" mva:VisualBasic.Settings="{x:Null}" sap2010:WorkflowViewState.IdRef="excel_password_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
xmlns:ui="http://schemas.uipath.com/workflow/activities"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Activities.Validation</x:String>
<x:String>System.Activities.XamlIntegration</x:String>
<x:String>Microsoft.VisualBasic</x:String>
<x:String>Microsoft.VisualBasic.Activities</x:String>
<x:String>System</x:String>
<x:String>System.Collections</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Windows.Markup</x:String>
<x:String>System.Xml.Serialization</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Drawing</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>UiPath.Core</AssemblyReference>
<AssemblyReference>UiPath.Core.Activities</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence DisplayName="excel_password" sap2010:WorkflowViewState.IdRef="Sequence_2">
<Sequence.Variables>
<Variable x:TypeArguments="sd:DataTable" Name="dt" />
<Variable x:TypeArguments="x:String" Name="dt_op" />
</Sequence.Variables>
<ui:ReadRange AddHeaders="True" DataTable="[dt]" DisplayName="Read range" sap2010:WorkflowViewState.IdRef="ReadRange_1" Password="uipath" SheetName="Sheet1" WorkbookPath="dummy.xlsx">
<ui:ReadRange.Range>
<InArgument x:TypeArguments="x:String">
<Literal x:TypeArguments="x:String" Value="" />
</InArgument>
</ui:ReadRange.Range>
</ui:ReadRange>
<ui:OutputDataTable DataTable="[dt]" DisplayName="Output data table" sap2010:WorkflowViewState.IdRef="OutputDataTable_1" Text="[dt_op]" />
<WriteLine DisplayName="Write line" sap2010:WorkflowViewState.IdRef="WriteLine_1" Text="[dt_op]" />
<ui:MessageBox Caption="{x:Null}" ChosenButton="{x:Null}" Buttons="Ok" DisplayName="Message box" sap2010:WorkflowViewState.IdRef="MessageBox_1" Text="[dt_op]" TopMost="True" />
<sads:DebugSymbol.Symbol>dyxDOlxVc2Vyc1xtbWlhb1xEb3dubG9hZHNcZXhjZWxfcGFzc3dvcmQueGFtbA47A0sOAgEBQAVGFAIBDUcFR48BAgEISAVIaAIBBUkFSbUBAgECQC9ANQIBEkMLQzoCARFAhgFAjgECARBAmQFAoQECAQ9ArwFAuwECAQ5HgwFHjAECAQtHI0cpAgEJSFxIZQIBBkmaAUmjAQIBAw==</sads:DebugSymbol.Symbol>
</Sequence>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="ReadRange_1" sap:VirtualizedContainerService.HintSize="314,87" />
<sap2010:ViewStateData Id="OutputDataTable_1" sap:VirtualizedContainerService.HintSize="314,22" />
<sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="314,61" />
<sap2010:ViewStateData Id="MessageBox_1" sap:VirtualizedContainerService.HintSize="314,59" />
<sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="336,473">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="excel_password_1" sap:VirtualizedContainerService.HintSize="376,553" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
Use Excel application scope and read the excel through that.
when you use excel application on your right hand side,under file you have a field called Password.
Enter the password which would make the excel sheet open.
This should work

spring integration xpath namespace issue

I am trying to use an an xpath expression, in order to read requestId field in the xml file given below. however, this expression results in no matches. When I try to enclose the field names with single quotes, it results in a compilation error. I even tried using local-name, instead of name, in the xpath expression. I need to be able to get the value of requestId field as shown.
<int-file:outbound-channel-adapter
id="file" mode="APPEND" charset="UTF-8"
directory="C:\\Users\\dvenkat1\\Desktop\\test"
auto-create-directory="true" filename-generator-expression="#xpath(payload, '/*[name()=Envelope]/*[name()=Body]/*[name()=processArchiveRequest]/*[name()=fulfillmentRequest]/*[name()=requestHeader]/*[name()=requestID]/text()')" />
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sch="http://...schema">
<soap:Header/>
<soap:Body>
<sch:processArchiveRequest>
<sch:fulfillmentRequest>
<sch:requestHeader>
<sch:requestID>Samplereq</sch:requestID>
............
Another option would be, is to use something like this:
<int-file:outbound-channel-adapter
id="file" mode="APPEND" charset="UTF-8"
directory="C:\\Users\\dvenkat1\\Desktop\\test"
auto-create-directory="true" filename-generator-expression="#xpath(payload, 'reference exp1 here']) " />
<int-xml:xpath-expression id = "exp1"
expression="name(/soapNs:Envelope/soapNs:Body/schNs:processArchiveRequest/schNs: fulfillmentRequest/schNs:requestDetail/*[1])"
namespace-map="archiveNamespaceMap" />
<util:map id="archiveNamespaceMap">
<entry key="soapNs" value="http://www.w3.org/2003/05/soap-envelope" />
<entry key="schNs" value="http://blah../schema" />
</util:map>
It works for me like this:
filename-generator-expression="#xpath(payload, '//*[local-name()="requestID"]')"
Pay attention to the escaped " symbol.
Regarding <int-xml:xpath-expression>.
You can use it from the the filename-generator-expression as well, but you should follow with the XPathExpression and therefore use XmlPayloadConverter manually. And do that everything somewhere from the custom bean.

XML parsing for nested tags using python

i would need a help on how to parse xml files with nested tags taking the user input as attribute value of a particular tag.
for eg:
if xml code has 12 mappings and we want to select the below mapping name "m_IF1_TD_SALESORDER_STG_PR4_VBPA_BUSINESS_PARTNER" as user input and thereby printing the particular mapping details.
<MAPPING NAME="m_IF1_TD_SALESORDER_STG_PR4_VBPA_BUSINESS_PARTNER" DESCRIPTION="Data Mapping for loading Sales Order Business Partners from the staging database for PR4." OBJECTVERSION="1" ISVALID="YES" VERSIONNUMBER="1">
<TRANSFORMATION NAME="sq_STG_PR4_VBPA" DESCRIPTION="" TYPE="Source Qualifier" OBJECTVERSION="1" REUSABLE="NO" VERSIONNUMBER="1">
<TRANSFORMFIELD NAME="MANDT" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="3" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="MANDT" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="VBELN" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="10" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="VBELN" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="POSNR" DESCRIPTION="" DATATYPE="decimal" PORTTYPE="INPUT/OUTPUT" PRECISION="6" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="POSNR" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="PARVW" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="2" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="PARVW" EXPRESSIONTYPE="GENERAL"/>
I would suggest using the XML ElementTree module of python.
It is very simple to use. For example:
import xml.etree.ElementTree as ET
tree = ET.parse('/filename.xml')
root = tree.getroot()
for subchild in root.findall('subchildName'):
print(subchild.get('subchildAttribute')

add icon instead of label in link

I'd written this code:
<action method="addLink" translate="label title" module="checkout">
<label>Cart</label>
<url helper="checkout/url/getCartUrl"/>
<title>Cart</title>
<prepare/>
<urlParams/>
<position>150</position>
</action>
But instead of the label Cart I want to show an image. How could I add image in the above xml code?
<action method="addLink" translate="label title" module="checkout">
<label>Cart</label>
<url helper="checkout/url/getCartUrl"/>
<title>Cart</title>
<prepare/>
<urlParams/>
<position>150</position>
<liParams />
<aParams><![CDATA[ class="cart"]]></aParams>
</action>
This should add a class cart to the <a> element. You can add your css on that class that hides the text and displays an icon.

Resources