Localize your dates

You go trough the trouble of building a website for multiple languages but the generated dates appear only in the server locale...
Sounds familiar? Here's a quick and easy fix, I hope you enjoy it!

First, create a new UDT for every language you wish to support.
In the example we are going to use the Dutch locale with the following name: "time_locale_nl"

setlocale (LC_TIME, 'nl_NL.UTF8');

Then, paste this at the absolute top of your template before any other code:

{time_locale_nl}

Done, your dates will now appear in Dutch! :)

If you don't want to use different templates for all the languages you want to support, you can use something like this in your template:
(supposing your Dutch pages are located under "2" and your French pages are located under "3" in the tree structure...)

{if $friendly_position|truncate:1:"" == 2}
{time_locale_nl}
{elseif $friendly_position|truncate:1:"" == 3}
{time_locale_fr}
{/if}

Comments