TYPO3 fluid translate view helper: No output when using "%0A%0A" in xlf file - typo3

In my fluid Template I am using
{f:translate(key:'LLL:path/to/file/locallang.xlf:Test', arguments: {0: 'Test'})}
Positive test case
Content of locallang.xlf:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2016-12-06T14:00:00Z" product-name="">
<header/>
<body>
<trans-unit id="Test" xml:space="preserve">
<source><![CDATA[mailto:info#example.org?Subject=%1$s&Body=Hello%0A]]></source>
</trans-unit>
</body>
</file>
</xliff>
Output:
mailto:info#example.org?Subject=Test&Body=Hello
Negative test case
Content of locallang.xlf:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2016-12-06T14:00:00Z" product-name="">
<header/>
<body>
<trans-unit id="Test" xml:space="preserve">
<source><![CDATA[mailto:info#example.org?Subject=%1$s&Body=Hello%0A%0A]]></source>
</trans-unit>
</body>
</file>
</xliff>
Output is an empty string
What is causing the empty output instead of the expected, encoded double line break?
I just found the underlaying PHP error message:
#1: PHP Warning: vsprintf(): Too few arguments in LocalizationUtility.php line 115

The character '%' should be escaped as '%%' as described in the PHP documentation for sprintf
This leads to
<source><![CDATA[mailto:info#example.org?Subject=%1$s&Body=Hello%%0A%%0A]]></source>
instead of
<source><![CDATA[mailto:info#example.org?Subject=%1$s&Body=Hello%0A%0A]]></source>

Related

What is wrong with my layer.xml from netbeans?

I try to create a new palette in netbeans 10, but the following 2 errors don't allow me to compile the project:
Document root element "folder", must match DOCTYPE root "JavaPalette". [3]
The markup in the document following the root element must be well-formed. [11]
My XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<folder name="JavaPalette">
<folder name="Items">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
<file name="Item.xml" url="resources/Item.xml">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
</file>
</folder>
</folder>
<filesystem/>
I have no clue what both error messages mean, but i did exactly what is said in the tutorial.
Online validation of the xml file also shows that error.
https://platform.netbeans.org/tutorials/nbm-palette-api2.html
I didn´t followed the tutorial, but as far as i can tell, your filesystem tag is not valid. If you take a look at the DTD you can see that the element filesystem isn´t declared as EMPTY (for more information you can read more about it here). So you have to provide a start and end tag. In your posted example you are only using <filesystem/> which isn´t allowed.
You have to change the xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="JavaPalette">
<folder name="Items">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
<file name="Item.xml" url="resources/Item.xml">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
</file>
</folder>
</folder>
</filesystem>

Extra namespace in xsl output eclipse

Since our company is moving from AX to SAP I'm also making a 'shift' from visual studio to eclipse. I'd thought it would be nice to start with a small xslt project but when trying my existing (made in VS) xsl I noticed some differences.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="msxsl:SalesType">
<xsl:choose>
<xsl:when test="(../msxsl:SalesType) = 'ReturnItem'">
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">384</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Generates an output xml with msxsl prefix xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope
xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read
</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<msxsl:MessageType
xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</msxsl:MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
Whereas visual studio xsl leaves out the xmlns:msxsl specification (which is correct):
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<MessageType>380</MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
Since it’s already in the http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice namespace
I don’t want this addition here. Is there anything I can do to change this in eclipse?
Kind regards,
Mike
No, Visual Studio is NOT correct to omit this namespace. If you don't want it included you should explicitly omit it using xsl:exclude-result-prefixes="msxsl".

How do you translate EXT:Form forms in TYPO3 CMS 8.7 LTS?

I'm new to TYPO3 and starting out with 8.7 LTS. I have created several forms with the default "form" extension. My site requires some of these forms to be translated into up to 5 other languages. So far the only solution I've found is to copy the forms and then have a separate form for each translation, but this does not seem like the best solution, as long term it would lead to form divergence.
Is it possible to add alternate translations directly in the YAML file or point to a translation file that should be used?
Here an example, like I use on a page:
For frontend translation add this to your typoscript setup:
plugin.tx_form {
settings {
yamlConfigurations {
100 = EXT:my_site_package/Configuration/Yaml/CustomFormSetup.yaml
}
}
}
"my_site_package" has to be an existing and activated TYPO3 extension
then make an yaml file under my_site_package/Configuration/Yaml/CustomFormSetup.yaml
TYPO3:
CMS:
Form:
prototypes:
standard:
formElementsDefinition:
Form:
renderingOptions:
translation:
translationFile:
# default translation files for the frontend
10: 'EXT:form/Resources/Private/Language/locallang.xlf'
20: 'EXT:my_site_package/Resources/Private/Language/locallang.xlf'
and have some translation files in my_site_package/Resources/Private/Language
default (en): my_site_package/Resources/Private/Language/locallang.xlf
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file source-language="en" datatype="plaintext" original="messages" product-name="tamods">
<header/>
<body>
<trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
<source>Object</source>
</trans-unit>
</body>
</file>
</xliff>
german (de): my_site_package/Resources/Private/Language/de.locallang.xlf
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" product-name="tamods">
<header/>
<body>
<trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
<target>Objekt</target>
</trans-unit>
</body>
</file>
</xliff>
german (fr): my_site_package/Resources/Private/Language/fr.locallang.xlf
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file source-language="en" target-language="fr" datatype="plaintext" original="messages" product-name="tamods">
<header/>
<body>
<trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
<target>Objet</target>
</trans-unit>
</body>
</file>
</xliff>
this is yaml from the form I am using:
renderingOptions:
submitButtonLabel: Senden
type: Form
identifier: ticketbestellung
label: Ticketbestellung
prototypeName: standard
renderables:
-
renderingOptions:
previousButtonLabel: 'previous Step'
nextButtonLabel: 'next Step'
type: Page
identifier: page-1
label: Page
renderables:
-
defaultValue: ''
type: Text
identifier: objekt
label: Objekt
properties:
fluidAdditionalAttributes:
placeholder: Objekt
required: required
validators:
-
identifier: NotEmpty
Some translation key, which are hard to find:
for Submit Button
element.Form.renderingOptions.submitButtonLabel
element.ticketbestellung.renderingOptions.submitButtonLabel
for Subject in E-Mail finisher
finisher.Email.subject (workaround, working also before Version 8.7.5)
finisher.EmailToReceiver.subject (should be the solution was buggy till Version 8.7.5)
This answer would be not possible without the help from manuel-selbach in the TYPO3 Slack.
There is a (work in progress) documentation for the new Form Framework introduced with TYPO3 CMS 8 LTS.
You can find the translation docs here:
https://docs.typo3.org/typo3cms/drafts/code.tritum.de/TYPO3.CMS/Form_Documentation/Concepts/FrontendRendering/Index.html#translation
Here is how you register this file:
https://docs.typo3.org/typo3cms/drafts/code.tritum.de/TYPO3.CMS/Form_Documentation/Concepts/Configuration/Index.html#yaml-registration
Here you can find information about "What is a site package":
https://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages
And here you can find more information about the Architecture of Extensions:
https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/Index.html
Most of the form documentation (first and second link) is already translated to english, but some parts are still in german.
I know this is a lot of stuff to read, but after reading you will have a basic knowledge about "How to build a website with TYPO3 (and translate the forms).
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file source-language="en" target-language="fr" datatype="plaintext" original="messages" product-name="tamods">
<header/>
<body>
<trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
<source>Object</source>
<target>Objet</target>
</trans-unit>
</body>
</file>
</xliff>

How to read xml value with Powershell

<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>
How can I read in powershell Tier Path value?
I am expecting to get the value of \\10.10.44.61\Case Study\
$xml = '<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>'
([xml]$xml).Foo.Tier.Path
As long as you are using an xml type (which I do by casting) you can reference the path directly as members of the object.

NANT: Style task passing parameter to xslt

I have a problem with passing arguments from the NAnt style task to a xslt sheet.
This is my NAnt code snippet. The properties path and file are definetly set.
<style style="${xslt.file}" extension="xml" in="${xml.file}" destdir=".">
<parameters>
<parameter name="path" value="${path}"
namespaceuri="http://www.w3.org/1999/XSL/Transform" />
<parameter name="doc" value="${file}"
namespaceuri="http://www.w3.org/1999/XSL/Transform" />
</parameters>
</style>
My Parameter are declared as following:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:param name="path"></xsl:param>
<xsl:param name="file" />
And accessed by:
<xsl:value-of select="$path" />
<xsl:value-of select="$file" />
But when the file is transformed, $path and $file are both empty. I have tried with and without the namespaceuri of the style task.
What I am doing wrong?
Thanking you in anticipation.
Hmmm, why do you set $file and use $doc ?
BTW, here is a working example:
<style style="web.config.xsl" in="web.config.xsl" out="web.config">
<parameters>
<parameter name="OSVersion" value="${OSVersion}"/>
</parameters>
</style>
and the XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="OSVersion"/>
<xsl:template match="/">
<xsl:value-of select="$OSVersion"/>
</xsl:template>
</xsl:stylesheet>
I just encountered the phenomenon Dennis described in his comment on the first answer. It seems that NAnt only executes the XSLT again if it has changed and doesn't notice that you have changed the parameters for the <style> element. Hence, once you have added your <parameter> elements to your NAnt file, running NAnt will not cause the XSLT to run with the new parameter values unless you have changed the XSLT file itself.