Language
How to easily work with language files
Assigning language values to a template can be a boring and repetitive process, as always on Tequila, we want to work less.
File structure:
Your page takes the language resources from:
A global language file
A page specific language file
Global language file.
All values common to an application should be stored in this file, i.e.:
Ok button,
cancel button,
general error messages
Page language file
Follow the same naming as the view and contain language values for only this page
Structure of the language file
The language file is created as a Multidimensional array to allow values to be processed as groups,
i.e.
$lang['label']['lbl_headertext'] = 'lbl_headertext';
In this case ‘label’ is the group, which allow the group to be processed together
Language assignment
Group assignment
There are many ways of doing this, if you need to replace 20 different tags in the same section of a document, simply group them as mentioned before, i.e. ‘label’ or ‘results’ and then assign them in one single instructions
$this->setlang(‘label’);
You can still assign single values, or use the traditional assign, the value of the setlang function is:
Avoid calling global for $lang
Process one or many values together
Reduce the amount of code and time to create pages
Single value assignment
You can use the same function with 2 parameters:
$this->setlang(‘label’, ‘lbl_headertext);
Or use the template functions instead
Global $lang; // Get access to the language resources
$this->template->assign(‘placeholder’, $lang[‘label’][‘lbl_headertext’]);
Strategies assignment
Strategies follow a similar pattern, you can call the function addlang, check Using strategies to view the whole functionality.
public function addlang($key, $subkey=null, $scope='block')