Translation for TYPO3 Backend Content Elements - typo3

How can I get a translation string in TYPO3 Backend?
In language overview in Backend, I have my custom Content Elements displayed.
If there is no link title set, the button has a language specific default value:
EN: Read more
DE: Mehr erfahren
In Frontend, we have <f:translate, but in Backend this does not work?
Version: TYPO3 V10 LTS

depending on where your label is. the string is defined in TCA (Table Configuration Array) or Flexform. in both cases you use an LLL reference instead of the label
usually somthing like this:
LLL:EXT:my_ext/Resources/Private/Language/backend.xlf:my_label_name
let me pick explain the diffrent parts:
LLL: proccess this aht Local Language resource (similar to http: in an URL)
EXT: this is an Extension Path chheck prefixes like typo3conf/ext/ or typo3/sysext
my_ext/Resources/Private/Language/backend.xlf the path to the file
:my_label_name the label inside the file

<f:translate> does work in the backend as well.
The language file should at least look like:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-08-22T11:22:55Z" product-name="efemtpy">
<header/>
<body>
<trans-unit id="title">
<source>Title</source>
</trans-unit>
</body>
</file>
</xliff>
Maybe you forgot the <source>-Tag like I did before.

Related

Accessing DOM element with namespace in Freemarker template

I have the following XML
<wmi xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd">
<wmiHeader>
<fileID>693401.20160229.130342.3541254</fileID>
<version>2.0.0</version>
<messageType>FSN</messageType>
<genDate>2016-02-29T13:03:42Z</genDate>
<from>
</from>
</wmiHeader>
<orderShipNotification>
<shipmentHeader dateTimeCreated="2016-02-29T13:03:42Z" requestNumber="2574445351883" />
<shipmentDetails actualShipmentDateTime="2016-02-29T12:18:54Z" carrierCode="XX" carrierMethodCode="XX-01">
<shipmentPackDetails trackingNumber="9361289672090007124848" trackingURL="https://example.com/go/TrackConfirmAction_input?qtc_tLabels1=323434">
<shipmentPackLineDetails requestLineNumber="1" partnerItemID="FXT-CC-LB" itemQtyShipped="1" />
</shipmentPackDetails>
</shipmentDetails>
</orderShipNotification>
</wmi>
I am getting error in Freemarker template when I am trying to access.
${orderShipNotification.shipmentDetails.#actualShipmentDateTime[0]!""}
If I delete the namespaces from the document it is working fine. I deleted the following content from the XML
xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd"
I did some investigation. The is a ftl directive. But it is still not clear how this will solve the problem. Please let me know how I can access the attributes.
http://freemarker.incubator.apache.org/docs/ref_directive_ftl.html#ref.directive.ftl
Start the template with
<#ftl ns_prefixes={"D":"http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment"}>
This sets the namespace as the default (D stands for default). Note that if you will also use XPath queries, there you will have to write out the D: before the element names (this is an XPath restriction).
This is documented here: http://freemarker.org/docs/xgui_imperative_learn.html

Typo3 Multilingual

I want to do a Multilingual Version of my Extension. In case of this I completed the Resources/Private/Language/locallang.xlf
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xliff version="1.0">
<file source-language="de" datatype="plaintext" original="messages" date="2014-12-16T23:29:45Z" product-name="rere" target-language="en">
<header/>
<body>
<trans-unit id="tx_rere_domain_model_note">
<source>Note</source>
<target>Note</target>
</trans-unit>
<trans-unit id="tx_rere_domain_model_note.notenr">
<source>Notenr</source>
<target>Notenr</target>
</trans-unit>
It's a valid xml file.
Then I added in the html files this:
<f:translate key='tx_rere_domain_model_note'/>
But in the view there isn't shown anything ... als is blank
what's going wrong?
To switch to other languages you need to include a Navigation that lets you do just that. Language Menus are just a special type of navigation in Typo3.
Look up, what uids your languages are assignes to in the sys_language table - usually 0 is the default, and every language you add gets an entry with a uid incremented by one - so, given 0: english, 1: german, the most basic configuration would look like this:
lib.languages = HMENU
lib.languages {
special = language
special.value = 0,1
}
It's explained more thoroughly in the reference:
http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.html#hmenu-special-property
Remove the extension key. You don't need it as long as your view is inside the same extension. Try this:
<trans-unit id="note">
<source>Note</source>
<target>Note</target>
</trans-unit>
<f:translate key='note'/>

Formhandler error message is not translated

I'm using the Typo3 Formhandler extension to build a simple reaction form. The form works correctly only the error response is in English and not translated. By typoscript I included a languest file.
langFile = fileadmin/templates/sandraverdijck/lang/newsletter.xml
The languest file includes the Dutch translation, see file below.
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<data type="array">
<languageKey index="default" type="array">
<label index="error_sender_name_required">Naam is verplicht</label>
<label index="error_sender_email_required">Email is verplicht</label>
<label index="error_sender_email_email">Email is niet correct ingevult</label>
</languageKey>
</data>
</T3locallang>
The response is still in English like "Your name is missing", I don't know where it gets this from and why it is not using the text from the languest file? When I don't include the languest file I get an error so the file is used. Anyone some idee?
Your language key is default. Is Dutch the default language of the website? Are you setting the language through
config.language = dk
? If so, try using the according language code in the XML file:
<languageKey index="dk" type="array">

typo3: issue with locallang xml

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>database</type>
<description>Language labels for extension 'dagou_user'</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<!-- Email -->
<label index="email_notify_employer_body"><![CDATA[A new Employer has signed up!<br /><br />Account Name: ###USERNAME###<br />Email: ###EMAIL###<br />Full Name: ###NAME###<br />Company Name: ###COMPANY###<br />Location: ###CITY### ###STATE###, ###ZIP###]]></label>
<label index="email_notify_employer_subject">New Employer</label>
...
</languageKey>
</data>
</T3locallang>
Above code is taken from locallang_dagouuser.xml, meanwhile I am reading this document: http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/7/2/
Questions:
For type="array", is there any other value I can assign for type? such as type="string"...
<type>database</type>, in the document, it is said "database" : Used for labels of database tables and fields., what does this mean? how could I use these labels with DB tables and fields?
No, there is just this one type.
This is just a hint for the reader what the purpose of this language file is. When you take at look at the TCA of the extension, you will see something like
'label' => 'LLL:EXT:cms/locallang_ttc.xml:sys_language_uid_formlabel'
This is one of the places those language labels for database fields are used.

How to add a colorized HTML code snippet in Sandcastle documentation?

I am using the Sandcastle Help File Builder and would like to include colorized HTML code snippets in the "Conceptual Content". Is this possible and if so, how?
I have tried <code>, <codeExample>, and <sampleCode language="HTML" />.
The best result so far is to HTML-encode the sample HTML and place it in a .snippets file like so.
<?xml version="1.0" encoding="utf-8" ?>
<examples>
<item id="htmlSnippet">
<sampleCode language="HTML">
<span>My Html</span>
</sampleCode>
</item>
</examples>
Then reference it in the .aml file.
<codeReference>htmlSnippet</codeReference>
I would prefer to have it colorized, but I can't figure out a way to add the formatting.
According to the MAML Guide, the proper way of doing this is to use a <code> tag with a CDATA section:
<code language="xml" title="Example Configuration">
<![CDATA[
<span>My Html</span>]]>
</code>
The contents of the CDATA section will be treated as a literal string, and indentation will be preserved.
I know this is old, but Sandcastle supports html as xml. I figured I should comment in case anyone else comes across this post as I did.
This should work:
<?xml version="1.0" encoding="utf-8" ?>
<examples>
<item id="htmlSnippet">
<sampleCode language="xml"><!CDATA[[
<span>My Html</span>
]]>
</sampleCode>
</item>
</examples>
If you're using Sandcastle Help File Builder, you may create your own syntax parser as described here and here, although xml is available by default... using the XAML filter's generator, which is defined here if you want to look at the config:
<generator type="Microsoft.Ddue.Tools.XamlUsageSyntaxGenerator"
assembly="{#SandcastlePath}ProductionTools\SyntaxComponents.dll">
<filter files="{#SandcastlePath}Presentation\Shared\configuration\xamlSyntax.config" />
</generator>
According to the SHFB documentation for the Code Block Component, you should be able to just use the <code>.
I got it to work without a problem; here's what I did:
test.html
<html>
<head>Something!</head>
<body>
<h1>Heading</h1>
<!-- #region myhtml -->
<p>Paragraph</p>
<div>Div for <strong>Good</strong> <em>measure</em>.</div>
<!-- #endregion -->
</body>
</html>
SomethingorOther.aml
<code language="html" source="../Examples/test.html" region="myhtml" />
Result:
Please note that in the preview, your sample will appear as unhighlighted XML, but when you build the documentation, everything should like just fine.