If you look carefully, Blogspot, Facebook, Google, Amazon primarily, all these multinational companies have different directories for different languages.
What you can do is on your website, make a hyperlink with the country flag in a top right or left corner and thus, go to a different directory.
I think it's less painful and less likely to error.
Another thing you can do is to have a .txt file for a language. In that file, enter a list of the most common words of a language and then make a script where the words in the person's browser history are captured. If the words in the history match the words in the .txt file of the desired language, update the website to the language you want.
For example, a Frenchman has French words in his history. The script will capture these words and search for them in .txt files. When the words in the history match the words in the French language .txt file, the website updates.