Your question is relevant and the same, for me, is more about form and not about how.
I asked a question that I recommend reading:
MVC and dynamic language change
I can tell from experience that we should use a framework that implements an MVC for any of our PHP projects. I am not going to put the reasons here because it goes beyond the scope of the question, but it is true that some already give some logic for language control.
For those who, like me, professionally use their own framework and implement their own MVC and for various reasons are forced to find mechanisms to solve various problems. Language control is a problem to always take into account.
Get the browser language.
It is a practice to adopt. This way we are already following definitions that the browser itself ensures and that delivers us by tray.
However this may not be enough for some projects being that and again by experience a functional language change is desired while using it, or because someone locks access to a browser settings for example. But by default getting the language from the browser is clearly the way to take.
From that point on, I think the manipulation of a URL amigável
to set a language is a simple, efficient and very direct solution in a PHP project and not only.
normal access:
www.meuprojecto.com/[controlador]/[acção]/[parametros]
obtem as configurações do browser
access affecting the idol:
www.meuprojeto.com/pt/[controlador]/[acção]/[parametros]
força o idioma a ser pt "por exemplo"
With this approach the links are spread throughout the project and at any time can change the language.
The methodology for storing the selected language depends on your solution but saving to COOKIE can be one of them.
Thank you for your help.
– Pedro Piloto