The first thing we need to do is importing the LocalizationUtility:
Then we can use the static method translate to get the value of our translation.
We need to add the path of our language file and the trans-unit key if we wanna use multiple language files. LLL: defines the passed value as a language-label.
You can use this way if you just use the locallang.xlf inside your extension (Resources/Private/Language/locallang.xlf) . In that case the first parameter equals the trans-unit key and the second parameters your extension key.
Inside fluid templates you should use the f:translate view helper. Like in extbase there are multiple cases too.
The same functionality but inline style:
In this case the view helper uses the locallang.xlf inside your extension:
Translations must be added to the locallang.xlf file and cannot be added to other files with this example.
This is your case if you have more than one language file. LLL: defines the key as an language label that contains the path to the file and the trans-unit key. In this example the file name is:
It´s recommended but not required to store the language file inside your extension. If the language file is inside the fileadmin or other folders you could use LLL:fileadmin/bad_idea_to_do_that/locallang.xlf:my_key .