doublesecretagency / craft-siteswitcher

Site Switcher plugin for Craft CMS
MIT License
67 stars 7 forks source link

Locale short name? #9

Closed migswd closed 8 years ago

migswd commented 8 years ago

Is it possible to display locale shortname (FR / EN) instead of full name (FRANCAIS / ENGLISH) in your example?

{% set element = (category ?? entry ?? null) %}
<ul>
    {% for locale in craft.i18n.getSiteLocales %}
        <li><a href="{{ ll(locale.id, element) }}">{{ locale.nativeName|capitalize }}</a></li>
    {% endfor %}
</ul>
lindseydiloreto commented 8 years ago

When you loop through all locales, as in that example...

{% for locale in craft.i18n.getSiteLocales %}

... you will be dealing with a LocaleModel.

I highly recommend you read up on the LocaleModel to learn what properties and methods are available to it.

The one you are looking for is this...

locale.id