[TYPO3-english] TYPO3 6.2.x: translating mechanisms within and without extensions

Jigal van Hemert jigal.van.hemert at typo3.org
Fri Nov 7 21:28:56 CET 2014


Hi,

On 07/11/2014 15:49, Bert Hiddink [BENDOO e-work solutions] wrote:
> I would like to create a XML-language file I can use within my site
> and/or extensions.
>
> What I understood from here:
> http://stackoverflow.com/questions/20775407/how-to-use-xliff-outside-an-extension-in-typo3
>
> ...this could be done like this in Fluid:
>
> <f:translate
> id="LLL:typo3conf/ext/news/Resources/Private/Language/locallang.xml:more-links"
> />

Since TYPO3 CMS still supports global and system extensions I'd go for:
<f:translate 
id="LLL:EXT:news/Resources/Private/Language/locallang.xml:more-links" />

> ...
>      <data type="array">
>          <languageKey index="default" type="array">
>              <!-- Common -->
>              <label index="more-link">Read more</label>
> ...

> However, if I change the index-key to "my-var":
>
> <f:translate
> id="LLL:typo3conf/ext/news/Resources/Private/Language/locallang.xml:my-var"
> />
>
> ..it returns nothing...
>
> So what is happening here? Is News reading this language field from
> another file? If yes, from where? And why could I not add custom-fields?

Is the key "my-var" present in that locallang file? Probably not, so 
that would explain why it doesn't work.

Another limitation from the syntax you use is that it will only work for 
the default language. If the frontend uses a different language it will 
still only show the labels for the default language.

There is a nice solution: make yourself an extension and store a 
locallang file (xml or xliff will do) in Resources/Private/Language/. As 
long as the filename is "locallang" it will be loaded automatically.

You can use the labels anywhere (also in fluid page templates) by using:
<f:translate key="my-var" extensionName="myExtension" />
(of course use my-var and myExtension with the names of your label and 
your extension)
This way the selected language is also considered.

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list