As you can see, clever handling of i18n means that we do not need to touch the template. But now we have a problem: Although the dynamic text is translated, the static template text is not and is displayed in English. Also, other cultures have different formatting for other types of information such as the date, time, and currency.
To address this problem, Symfony comes with template helpers to aid us with localization of the templates.
Continuing our work on the vacancies page, one field that we can localize is the close date field. There are three types of helper groups—Date, Number
, and I18N—and
none of them are enabled by default. So let's set the culture on the date field. First, we must declare at the top of the template that we want to use the Date
helper. Therefore, in our apps/frontend/modules/vacanies/templates/indexSuccess.php
template, add the following to the first line:
<?php use_helper('Date') ?>
Now that the Date
helper is enabled, we can...