Jump to content

Translating inside a JS file?


Recommended Posts

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

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 by ZaxxaDK (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...