StefGuev
StefGuev

Reputation: 649

SilverStripe how translate date function in template?

I'm using Fluent module multilanguage support for SilverStripe 3.1 and there is no documentation for using the Date function into Templates.

The file fluent.yml have these configurations :

 ---
 Name: myfluentconfig
 After: '#fluentconfig'
 ---
 Fluent:
   default_locale: fr_CA
   locales:
     - en_CA
     - fr_CA
   aliases:
     en_CA: en
     fr_CA: fr
 ---
 Name: myfluenti18nconfig
 After: '#fluenti18nconfig'
 ---
 i18n:
   default_locale: fr_CA

I have also remove in mysite/_config.php :

 // i18n::set_locale('fr_FR');

That work great on my site. But how show dates in correct Language? If my Date variable is $date in my template, I can add $date.month to show the full month. But actually, it only appear in english on fr_CA site. So, Is it possible to show the french date in other ways?

Upvotes: 1

Views: 651

Answers (1)

wmk
wmk

Reputation: 4626

Date and localisation, a pita for every multilangual developer. FormatI18N should return the formatted string using strftime() depending on the current locale. It won't work if you have not installed your locale (fr_FR) on your server. Or if you use e.g. fr_FR@utf-8... I had to include this setlocale on a site of mine in mysite/_config.php to get it working:

setlocale(LC_TIME, "de_AT.utf8");

and overwrite it later in Page_controller::init(). (It's a translatable based site, fluent does that for you automatically)

So plese check the installed locales on your machine.

Upvotes: 1

Related Questions