Skip to Main Content

Multilingual Dates in ExpressionEngine

I've built about 15 multilanguage sites and have a good process for building them out using Transcribe, which I really enjoy using. Today I ran into something new for the first time. The site I'm working on needs to display entry dates, however there is no built in way with Transcribe or ExpressionEngine to translate the dates.

I've built about 15 multilanguage sites and have a good process for building them out using Transcribe, which I really enjoy using. Today I ran into something new for the first time. The site I'm working on needs to display entry dates, however there is no built in way with Transcribe or ExpressionEngine to translate the dates.

A quick search on Devot:ee later and I found Date/Time Language Converter by Carl Crawley. This little plugin is super easy to use. Below is my code to get a French/English site to display the dates in both languages. The key to notice is that the entry date tag that is wrapped by the datetime_convert tags has no formatting parameter.

    
    
      {if "{transcribe:language_abbreviation}" == "en"}
	November 06th 2013
{if:else}
	{exp:datetime_convert language="fr_FR" format="%B %e %Y"}1383751020{/exp:datetime_convert}
{/if}
    
  

Updated with alternate method

Jelle Dijkstra said:

what i did on a site with >5 languages was to create transcribe variables for the “fr_FR” and the desired formatting and display the formatted date like this:

Yogi Bear
    
    
      {exp:datetime_convert language=’{transcribe:language_abbreviation}_{exp:transcribe:replace name=“lang_iso”}’ format=’{exp:transcribe:replace name=“date_formatting”}’ parse=“inward”}{entry_date}{/exp:datetime_convert}
    
  

another benefit is that it’s easy to localise things like validationengine error messages etc