Mighty Language (JSL) component is very powerful Joomla 1.5 native component development tool, that allows to easily create language files for components you develop. Not only create core language file but also compare all translations and adding new indexed there. So you don’t anymore need to go manually through all the components files looking for all text and covering it into uppercase indexes and values in language file. Is in it boring? I hate this routine job. And this is why this component was created. To make us happy and concentrate on developing real features.
How it works
JSL Component looks through all your .php and .xml files except installation xml files and looks for strings that are needed to be included in the language file. In the PHP files it looks for all texts placed into JText class, and in the XML files it looks for tag attributes. They are:
- label
- description
- group
- and everything in the between of <option> and </option> tags
When JSL parses the component it saves all the Found Strings in the _ROOT_/ administrator/languages/en-GB/ folder for the back-end and _ROOT_/languages/en-GB/ for fromtend with en-GB.component_name.ini (i.e en-GB.com_banners.ini) file name.
The language files for the Frontend and Backend are different. In the frontend language files are only strings that are found in the frontend folder of the component and in the backend language file only strings that are found in the backend folder of the component.
If en-GB language files existed before parse, JSL saves all indexes and its translations of old file except not found one. Those are deleted. That means if you had string
Echo JText::_(‘This is the test’);
After first parse THIS IS THE TEST=This is the test line will be added to language file and if you delete this string from the code, THIS IS THE TEST=This is the test will be deleted on next parse.
On other hand if you changed THIS IS THE TEST=This is the test to THIS IS THE TEST=This is NOT a test, and do not delete Echo JText::_(‘This is the test’); from the code, index and its value will be kept on next parse.
If you want to add indexes that is not present in the code or simple is not found by JSL, they will be always deleted on each next parse. To solve this you should place those in CUSTOM ENTRIES section.
#** CUSTOM ENTRIES **# CUSOMTEXT=Here is the custom text that you would like to be added and that JSL could not find #** CUSTOM ENTRIES **# #----------FOUND WORDS-------------- ABOUT=About ACCESS=Access ACCESS LEVEL=Access Level
JSL have few reasons not to find indexes.
- When JText is called inside function of core Joomla classes. For example
<?php echo JHTML::_('grid.sort', 'Access', 'groupname', $this->lists['order_Dir'], $this->lists['order'] ); ?>
Here Access is treated by Text inside JHTML::_() function.
-
When you have to put text into JText like variable
<?php echo JText::_($text)?>
Those are cases when you can place those indexes into CUSTOM ENTRIES section.
JSL saves en-GB language files in Joomla standard language folders. Joomla_root/languages/en-GB/ and Joomla_root/administrator/languages/en-GB/
Extending the Your Language Files
One of the most routine and hard job in translation is a maintains of already translated files. In particular to look indexes that is added in en-GB language file on new parse and add them in to other language file for passing it to translator for future editing. JSL can do this for you automatically.
To enable this process you need to create folder names Language in component root as in front-end as in back-end. (i.e administrator/components/com_juser/languages and components/com_juser/languages) Put your language files other than English there accordingly. I mean translations for front-end to front-end component/languages folder and admin to back-end. So when you parse the component, new indexed not found in language file will be added with the empty values and already translated strings will remain untouched. You can have as many different files in languages folders as you want.
Development Suggestions
Here are few rules that you should follow for JSL component to work correctly.
Rule 1: Always Use JText class Functions.
When you are printing any kind of text to the browser except HTML tags make sure that you are using one of the JText class’s functions.
The functions are:
- JText::_(“Your Text”);
- JText::sprintf(“Your text %s”, variables…);
- JText::printf(“Your text %d”, variables…);
The text can be taken in double quotes(“text”) or single quotes(‘text’). If text is not in the any of these functions then it will not be added in the language file.
Rule 2: Avoid using variables inside JText
When you put parameter into JText::_() function, avoid put it as variable.
Incorrect:
<?php $var = “Some String Here”; Echo JText::_($var); ?>
Correct:
<?php Echo JText::_(“Some string here”); ?>
Correct 2:
<?php $var = JText::_(“Some String”); Echo $var; ?>
And for JText::printf() functions:
Incorrect:
<?php $placeholder = “Your age is %d and your name is %s”; JText::printf($placeholder, $age, $name); ?>
Correct:
<?php JText::printf(“Your age is %d and your name is %s”, $age, $name); ?>
And for the JText::sprint() is the same:
Incorrect:
<?php $placeholder = “Your age is %d and your name is %s”; JText::sprintf($placeholder, $age, $name); ?>
Correct:
<?php $output = JText::sprintf(“Your age is %d and your name is %s”, $age, $name); Echo $output; ?>
on 
+1 (424) 201 06 56,