xDateTrans

Translate date in the right language

Logo ResourceSpace Logo Wordpress Logo Prestashop Logo Joomla

xDateTrans is a output filter (modifier) for MODX to force date to display in the language defined by cultureKey context setting.

On some servers and configurations day weeks and months are not translated even if PHP Set locale information is defined. This snippet/modifier resolves this problem by translating days and months following the culture key language value.

Basic usage

The display language matches the cultureKey context setting value (for this site: en).

Just add the modifier at the end of a date TV or placeholder:

[[*createdon:strtotime:date=`%A  %e %B %Y`:xdatetrans]]

Output

Monday 4 November 2019

Force language

To force the display in a specific language, just add the language value as option.

Exemple to output date in French and Japanese:

French (fr)

[[*createdon:strtotime:date=`%A  %e %B %Y`:xdatetrans=`fr`]]

French: Lundi 4 Novembre 2019

Japanese (ja)

[[*createdon:strtotime:date=`%Y年 %B %e日(%A)`:xdatetrans=`ja`]]

2019年 11月 4日(月)

Spanish (es)

[[*createdon:strtotime:date=`%A %e de %B %Y`:xdatetrans=`es`]]

Lunes 4 de Noviembre 2019

Russian (ru)

[[*createdon:strtotime:date=`%A %e %B %Y r.`:xdatetrans=`ru`]]

Понедельник 4 Ноябрь 2019 r.