Use Joomla.JText._('LANGUANGE_CONSTANT') in any of the the js file
Include the file in the components view
Also use the JLoader import for replacing the language constant
& call the specified function
foe eg.
// Import helper for declare language constant
JLoader::import('ExampleFrontendHelper', JUri::root().'components/com_example/helpers/example.php');
// Call helper function
ExampleFrontendHelper::getLanguageConstant();
Enable the Mootools for the enable template & check the language constant working properly
Disable the mootools for the template & check the language constant not replaced properly.
It should also be working with the Mootools disbaled.
Not working without mootols
IS it necessary to enable mootools for using Joomla language constant in the js files?
Try to load core.js. The script that does the conversion is pretty vanilla BUT requires Joomla variable. I use it like this and it works here!
I guess you are already loading core.js (using JHtmlBehavior::core()
)?
core.js defines the Joomla
namespace for JavaScript functions and also defines the Joomla.JText
method.
Previously this was loaded together with the MooTools framework and it also depended on it.
Core.js was rewritten to jQuery recently (I think with 3.3.0) and thus we can now load it without loading MooTools. That's what JHtmlBehavior::core()
is for :)
Hello guys,
Thanks for your replies.
I found out this issues for the custom template.
It's having configuration for enabling bad disabling the mootools
Hence I though it should be used without mootools library in Joomla.
I hope you will take my opinion in consideration.
On Oct 22, 2014 8:05 PM, "Dimitri Grammatiko" notifications@github.com
wrote:
@wilsonge https://github.com/wilsonge I am trying to figure out why
this is happening looking at joomla/language/… and
document/html/renderer/head.php
But I get nowhere. Any hints?—
Reply to this email directly or view it on GitHub
#4839 (comment).
Labels |
Added:
?
|
Is this still an issue?
It shouldn't be because core.js is not mootools dependent
I have go through the issue description and also tested, found that it work without Mootools.
So, we can close this issue now.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-07-14 11:10:01 |
Closed_By | ⇒ | gunjanpatel |
Set to "closed" on behalf of @gunjanpatel by The JTracker Application at issues.joomla.org/joomla-cms/4839
Closed_By | gunjanpatel | ⇒ | joomla-cms-bot |
Yes it is necessary to have mootools for this. There are still (an ever decreasing number of) areas of javascript in the CMS that require mootools unfortunately and this is one of them!
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4839.