使用翻译的多语种网站

I have a website in PHP (solution in JAVA is also welcome) & I want to add multilingual support in my website. Strict specification is that when user wants to change language of the page it would get translated dynamically. I am not suppose to make N no. different of pages for different language. Is it possible ? If Yes how? I have gone through few plugin & web service such as Microsoft but they charge heavily that's why I want to do it on my own.

you could use a frontend translation tool such as https://localizejs.com/ (there are others); there you can add languages on the fly and as long as no human translations are available, the tool would use something like Google Translate as a fallback