0

I have a script that automatically translates my website into French, the problem is, the script translates the website for non french speakers too, so I want a way to load JS files (I will be including the translation script in one of those files) based on user's browser language, for example if the user is from France or speaking french, it will load the Javascript files, otherwise it will do nothing.

Regards.

kristian
  • 73
  • 1
  • 6
  • You probably want to serve two different pages entirely. That way every user who visits the page wont have to run the translation logic. You simply run it once when you publish the site, and let the web server handle the rest. – Olian04 Apr 13 '20 at 20:45
  • No I try to avoid that as much as I can, I don't want to serve two different pages with different translation, just a simple way to serve a javascript file based on user's default language, as an example French. I have seen others did it using PHP, I can use PHP too if that is possible. – kristian Apr 13 '20 at 21:31
  • PHP is a server-side language. PHP =/= javascript – Olian04 Apr 13 '20 at 21:33
  • Yes I totaly acknowledge that, but I would like a way either by Javascript or PHP, doesn't matter – kristian Apr 13 '20 at 21:34

0 Answers0