When I output {{ craft.locale }} in my template, I get the current locale’s ID (e.g. “en”) rather than its name (e.g. “English”).

How do I get the locale’s name?

  • For anyone coming here for craft.locale: It's deprecated, use craft.app.language now. Nov 20 '19 at 9:43

You can get the current locale’s name via craft.i18n.getCurrentLocale().

{% set locale = craft.i18n.getCurrentLocale() %}
{{ locale.name }}

That will output the name using the current locale’s translation.

If you would prefer to output the locale’s name in its native tongue, use nativeName instead:

{{ locale.nativeName }}

You can also output the name of any locale using (not necessarily the current one) using craft.i18n.getLocaleById():

{% set locale = craft.i18n.getLocaleById(entry.locale) %}
{{ locale.name }}
{{ locale.nativeName }}
  • Nice Brandon! Can you please add how to access the i18n name for non-current locales? Let's say all I have is a string "de". Thanks
    – carlcs
    Jul 10 '14 at 1:36
  • @ChristianSeelbach updated ;) Jul 10 '14 at 12:54
  • Thanks! I now have to update this answer a 6th time ;)
    – carlcs
    Jul 10 '14 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.