I have a big javascript file common.js
with all my functions and stuff…and i would like to write a separate file Js
to store only the definitions for all the alert/courtesy messages etc
spread along the file…i don’t want to seek and change one by one…
i have created something like this in php, where I have my file, en.php / fr.php /de.php for each language i need…
i was wondering:
1. if i can do the same in Js
2. if there is any way to use the php instead…so woudl be even better to have just one and only file to edit
thanks
Sure — all you need to do is to create a definitions file for each language that just creates an object with the needed
name: valuepairs. Your existing JS can then insertdefsObject["name"]wherever needed. Your PHP would then determine which of the JS definition files to load by changing thesrcvalue of the script tag.If you are unfamiliar with the object notation, there’s loads of examples available on Stack Overflow (tagged JSON).