-
Book Overview & Buying
-
Table Of Contents
Zend Framework 2 Cookbook
By :
In this recipe, we will explain localization and its uses. Localization differs from internationalization in the way that localization refers to, for example, numeric, date and time formats, and the use of currency.
In this recipe we will be discussing the ever so important localization of our application.
When a user hits our website, we most likely want the user to automatically go to the right language. Although, there are several methods of doing this, we will be using a manual check to see if the language the user prefers is also in our list of languages.
We do this by a couple of simple tricks:
First, we are getting the Accept-Language headers from the HTTP request
Then we iterate through them and see if one of the languages mentioned in the header matches the language we have
Lastly, we set the language to the language we have found, or if nothing is found, the fallback language is set
Let's see how this looks in our Module.php code:
/...
Change the font size
Change margin width
Change background colour