TYPO3 v12 - Localization is not working with xlf files - typo3

I am trying to get the translation to work in Typo3 12.1.3.
I build a simple site package following the Sitepackage Tutorial.
I added some locallang files:
locallang.xlf
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="EXT:site_package/Resources/Private/Language/locallang.xlf" date="2011-10-17T20:22:32Z" product-name="site_package">
<header/>
<body>
<trans-unit id="test" resname="test">
<source>Test (EN)</source>
</trans-unit>
</body>
</file>
</xliff>
de.locallang.xlf
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" datatype="plaintext" original="EXT:site_package/Resources/Private/Language/locallang.xlf" date="2011-10-17T20:22:32Z" product-name="site_package" >
<header/>
<body>
<trans-unit id="test" resname="test" approved="yes">
<source>Test (EN)</source>
<target>Test (DE)</target>
</trans-unit>
</body>
</file>
</xliff>
Created some template:
<f:layout name="Default" />
<f:section name="Main">
<main role="main">
<div class="container">
<div class="row">
<div class="col-md-12">
<f:translate key="LLL:EXT:site_package/Resources/Private/Language/locallang.xlf:test"/>
<f:translate key="test" extensionName="site_package"/>
<f:for each="{mainContent}" as="contentElement">
<f:cObject
typoscriptObjectPath="tt_content.{contentElement.data.CType}"
data="{contentElement.data}"
table="tt_content"
/>
</f:for>
</div>
</div>
</div>
</main>
</f:section>
And added a site configuration:
base: /
languages:
-
title: English
enabled: true
languageId: 0
base: /
typo3Language: default
locale: en_US.UTF-8
iso-639-1: en
navigationTitle: English
hreflang: en-us
direction: ltr
flag: us
websiteTitle: ''
-
title: Deutsch
enabled: true
base: /de/
typo3Language: de
locale: de_DE
iso-639-1: de
websiteTitle: ''
navigationTitle: Deutsch
hreflang: de-DE
direction: ''
fallbackType: strict
fallbacks: '0'
flag: de
languageId: 1
rootPageId: 1
websiteTitle: ''
Afterwards I created a site, added some content and translated it to German in the backend.
Problem:
The content elements are presented in the selected language in the frontend.
If I switch it, they are presented in the matching language.
The text from the locallang file stays in the default language.
If I switch the language, they are not presented in the right language. They stay in English.
What am I doning wrong?
Thanks a lot for your help!

can you check again with TYPO3 v12.2.0? This might solve these problems...

I have the same issue with TYPO3 v12.2 like the threadstarter. I'm using DDEV locally and the main content of the page is German and created a page translation to English. The output still remains in English.
The section for languages in the config.yaml file in my site configuration:
languages:
-
title: Deutsch
enabled: true
base: /
typo3Language: de
locale: de_DE.utf8
iso-639-1: de
websiteTitle: 'Meine Webseite'
navigationTitle: Deutsch
hreflang: de-DE
direction: ''
flag: de
languageId: 0
-
title: English
enabled: true
base: /en/
typo3Language: default
locale: en_US.utf8
iso-639-1: en
websiteTitle: 'My website'
navigationTitle: English
hreflang: en-US
direction: ''
fallbackType: fallback
fallbacks: '0'
flag: en-us-gb
languageId: 1
The German translation file de.locallang.xlf looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="EXT:custompackage/Resources/Private/Language/locallang.xlf" date="2020-10-18T18:20:51Z" product-name="custompackage" target-language="de">
<header/>
<body>
<!-- Topbar -->
<trans-unit id="topbar.book-appointment" resName="topbar.book-appointment" approved="yes">
<target state="translated">Termin online buchen</target>
</trans-unit>
</body>
</file>
</xliff>
The English (default) translation file locallang.xlf looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="EXT:custompackage/Resources/Private/Language/locallang.xlf" date="2020-10-18T18:20:51Z" product-name="custompackage">
<header/>
<body>
<!-- Topbar -->
<trans-unit id="topbar.book-appointment">
<source>Book appointment</source>
</trans-unit>
</body>
</file>
</xliff>
Fluid template, first with German default label, second without:
<f:translate extensionName="custompackage" id="topbar.book-appointment">Termin online buchen</f:translate>
<f:translate extensionName="custompackage" id="topbar.book-appointment"/>
The second variant returns the English label by default.
I also noticed changing the user backend language affects the frontend localization output. If German was set up as a user backend language, German labels appear in the frontend and with English the other way. That's a strange behavior. Any idea why this happens?
What's the right way to set up translations for own composer extensions?
Do they belong to var/labels/{language}/{customExtension} or the regular way to packages/{customExtension}/Resources/Private/Language/locallang.xlf? The localization documentation for TYPO3 v12 (main) shows the regular way.

I have the same problems like you both with TYPO3 12.2.0.
But I've made a mistake with my folder name. I created a folder named "Languages", but it has to be "Language".
So maybe check your convensions ... now the Localisation works fine with TYPO3 12. You don't need a second Website Language to show your data in different languages. You only need special files, like locallang.xlf for english and de.locallang.xlf for german.

Related

Multidomain multilanguage sites on single typo3 v10 installation

I have read all documentation and something that seems obvious is not happening in my installation. I have several domains:
domain.net
domain.fr
domain.it
all of them are pointing the typo3 folder in server. After adding all these domains and corresponding languages in site management > sites
I still only get original frontend in .net domain rest wont show anything (blank).
Note: most information online is older versions and it seems that this point has been simplified in this version, so there is no need to include any code in .htaccess or other files. Also followed this
Looking into my folder tree I can see these folders (for each site) in mainfolder/typo3conf/sites and every of them has its config.yaml file.
Substituted real name for "domain"
this is what .net looks like (english version)
base: 'https://example.net/'
baseVariants: { }
errorHandling: { }
languages:
-
title: English
enabled: true
base: 'https://example.net/'
typo3Language: default
locale: en_US.UTF-8
iso-639-1: en
websiteTitle: ''
navigationTitle: English
hreflang: en-US
direction: ltr
flag: en-us-gb
languageId: '0'
rootPageId: 1
routes: { }
websiteTitle: ''
This is .fr (french version)
base: 'http://example.fr/'
baseVariants: { }
errorHandling: { }
languages:
-
title: French
enabled: true
languageId: '0'
base: 'http://example.fr/'
typo3Language: fr
locale: fr_FR.UTF-8
iso-639-1: fr
navigationTitle: Français
hreflang: fr-fr
direction: ltr
flag: fr
websiteTitle: ''
rootPageId: 2
routes: { }
websiteTitle: ''
Tree inside is just this
Pages have dummy content we arent developing anymore until this problem is solved.
Any idea?
Server setup should be ok as before typo3 i was able to have a wordpress multisite and it did show content. As WP isnt native multilanguage and it works with all kind of plugins that just break everything when you update. This is why we are changing to typo3. But that is another story.
Usually when everything seems fine but it doesnt work, its something silly.
.fr domains and others were handling a lower version of php so it wouldnt run typo3
So if something like this happens to you check php version on every domain!!!

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>

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

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>

Eclipse Content Assist for composite components in JSF 2 don´t show

I,m developing a composite component to generate a selectOneMenu from a DB data list according to name pass by parameter.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:jsf="http://java.sun.com/jsf"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<cc:interface componentType="pseudocatalog" >
<cc:attribute name="paramsName" default="" displayName="paramsName" expert="false" hidden="false" preferred="true" shortDescription="Descripcion de prueba"/>
<cc:attribute name="paramsValue" default="" displayName="paramsValue" shortDescription="Descripcion de prueba"/>
<cc:attribute name="paramsType" type="java.lang.String" default="" displayName="paramsType" shortDescription="Descripcion de prueba"/>
<cc:attribute name="storedProcedure" type="java.lang.String" default="" displayName="storedProcedure" shortDescription="Descripcion de prueba"/>
<cc:attribute name="nextAutomatic" type="java.lang.Boolean" default="true" displayName="nextAutomatic"/>
<cc:attribute name="value" type="java.lang.String" default="" displayName="value"/>
<cc:attribute name="mode" type="java.lang.String" default="" shortDescription="" displayName="mode"/>
<cc:attribute name="autocomplete" type="java.lang.String" default="" displayName="autocomplete"/>
<cc:attribute name="loadDefaultOption" type="java.lang.Boolean" default="true" displayName="loadDefaultOption"/>
<cc:attribute name="order" type="java.lang.String" default="asc" displayName="order"/>
<cc:clientBehavior name="change" targets="#{cc.id}" event="change" />
</cc:interface>
<cc:implementation>
<h:selectOneMenu id="#{cc.id}" value="#{cc.attrs.value}" >
<f:selectItems value="#{cc.items}"/>
</h:selectOneMenu>
</cc:implementation>
</html>
And the new component renders fine but eclipse don´t show the content assistant for the attributes.
For another library components like rich or h the content assistant works fine
What´s wrong?
Not possible, at least, I couldn't achieve it. Eclipse is able to identify the tag name for the composite itself, but not its attributes. You can see it also in the docs. What you could do is to declare it as a tag library, so eclipse could recognize them parsing the declaration file.