Web page localization in php
Suppose I have two url for the same file, say http://site.com/fr/page.php
and http://site.com/en/page.php
.
In the end it is the exact same file that is executed, but the first url ouputs text in french, the second in english.
Using asp.net I would achieve that by setting the thread's Culture
and UICulture
property, then use two resx resources files to get the strings to display based on that culture.
How can I achieve something similar with php?
I have seen gettext, but as I understand it I cannot use it with different language on a per request basis. I'm not sure if setlocale
and putenv
affects all the request or just the current one.
I know that some frameworks may provide that functionality (zend_translate?)开发者_开发百科, but I don't want to use it. This project is mainly for me to learn, and I want it the most independant as possible.
setlocale
and putenv
affects just the current one. You can save your culture into session.
精彩评论