简体   繁体   中英

Multi-language website and .js files

My website is multi-language. I'm using php files to define my words / sentences in several languages.

My problem is that my website contains .js files, in which i can't write php code.

What I am suppose to do when I need to make an alert containing some sentence or some word in my .js file ?

Thanks

You COULD have your js utilize a json obj or an array of strings...

PHP could then create these and write the json or array in the head section on page load..

您可以将JS文件另存为FILENAME.js.php ...在其中可以运行一些Magic。

Ajax and JSON is the best way to do this. But you can actually make put PHP is javascript files, with a little htaccess manipulation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM