Accessing Locale Data from Templates

Yii, the framework that Craft is built on, ships with a tremendous amount of data for various locales, pulled from the Unicode Common Locale Data Repository. (You can see it all by peeking in craft/app/framework/i18n/data/.)

Craft exposes it in its templates, via craft.i18n.getLocaleData():

{% set localeData = craft.i18n.getLocaleData() %}

<select name="month">
    {% for month in localeData.getMonthNames() %}
        <option value="{{ loop.index }}">{{ month }}</option>
    {% endfor %}
</select>

By default, getLocaleData() will return data for the active locale (whatever craft.locale returns), but it’s possible to override that by passing in a different locale ID:

{% set month0 = now.month - 1 %}

{% for locale in craft.i18n.getSiteLocales() %}
    {% set localeData = craft.i18n.getLocaleData(locale.id) %}

    <p>
        Month in {{ locale.name }}:
        {{ localeData.getMonthName(month0) }}
    </p>
{% endfor %}