ZaxxaDK Posted August 6, 2016 Share Posted August 6, 2016 Hey guys i last couple of days i have had many questions to my first prestashop module, and now im here again When working with a .JS file, how do i handle the translation? I have a JS filled called myJavaScript.js, that i inject into the header of my plugin - and inside that file i have some stuff i want to have translated. I read about the {literals}, and tried to put it around my code - but didnt quite seem to be able to get it to work! so maybe somebody can point me in the right direction ? Link to comment Share on other sites More sharing options...
NemoPS Posted August 6, 2016 Share Posted August 6, 2016 You can use addJsDefL actually: http://nemops.com/prestashop-functions-5/#.V6Wx3IP5jmgSee the section named Adding javascript variable definitionsThat works if you are inside a template and your js uses jquery with document.ready.If not, you can use Media::addJsDefL from your php, before including the js file into the header Link to comment Share on other sites More sharing options...
ZaxxaDK Posted August 6, 2016 Author Share Posted August 6, 2016 (edited) You can use addJsDefL actually: http://nemops.com/prestashop-functions-5/#.V6Wx3IP5jmg See the section named Adding javascript variable definitions That works if you are inside a template and your js uses jquery with document.ready. If not, you can use Media::addJsDefL from your php, before including the js file into the header Where do i add this addJsDefL / Media::addJsDefL ? i dont want to overwrite some of the prestashop standart behaviour - but i looks very smart if it works how i think it does Edited August 6, 2016 by ZaxxaDK (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted August 8, 2016 Share Posted August 8, 2016 In the same php method (usually hookDisplayHeader) you use to add your js. I take it as you are following standards. If not, check out the other Essential PrestaShop functions tutorials Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now