The sfUser
class provides both getter and setter methods for retrieving and setting a user's culture. This means that we can modify the culture for the user if we need to. We might do this if, for example, we had another translation and the user selected it.
To retrieve the culture, you would use the sfUser
objects' getCulture()
method:
To set the culture, use the sfUser
objects' setCulture()
method:
$this->getUser()->setCulture('en_AU');
As part of a request, your web browser includes the HTTP header Accept-Language
. This tells the server what your preferred language is set to. For example, the Accept-Language
header in my browser is:
Accept-Language en-au,en-gb;q=0.7,en;q=0.3
But a French user's browser might contain this:
Accept-Language fr;q=1.0,en;q=0.5
The header not only denotes the preferred language, but also the priority. The French user will obviously prefer French followed...