[solved] Use of the global TL_LANG inside of local templates
Hi Contao Developers!
I'm currently trying to get some translations stored in a file inside the "en" directory in my module (mymodule/languages/en/my_language_file.php) directly into a template file located in TL_ROOT/templates/my_template_file.xhtml.
This is a temporary measure since I will put this template file in the module directory in a few months (once i get enough time to make it properly). Just in case someone feels the need to ask why ; )
Unfortunately, the global variable TL_LANG is not available in this environment. Is there a way to make it so?
Btw, I would appreciate it if someone could enlighten me about the internationalization system. Where in the code is located the lecture of all language files of all modules? I did some research but didn't found anything...
Thanks for the help!
Re: Use of the global TL_LANG inside of local templates
I finally find out the answer to my question.
The System class give us access to a marvellous function that is loadLanguageFile(), knowing that it is now easy to load any language file into a local template.
The example below show you how to load the tl_form.php file located in system/modules/backend/languages/en/tl_form.php.
[code=php:2ufpy8fm]<span class="syntaxdefault">
</span><span class="syntaxcomment">//*No*need*for*the*.php*suffix*here.
</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">loadLanguageFile</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'tl_form'</span><span class="syntaxkeyword">);
</span><span class="syntaxdefault">*</span>[/code:2ufpy8fm]