I'm trying to loop on locales to get the path to the current entry, but for the other locales (for a language switcher).
Here is my code:
{% set locales = craft.i18n.getSiteLocales() %}
{% for locale in locales %}
{% set localeEntry = craft.entries.id(entry.id).locale(locale.id).first %}
{{dump(localeEntry.locale)}}
{{dump(localeEntry.getUrl()) }}
{% endfor %}
Results:
"en"
"http://website.dev/en/page"
"en_gb"
"http://website.dev/en/page"
"en_us"
"http://website.dev/en/page"
"de"
"http://website.dev/de/page"
The language only versions are fine en
and de
, though the language-location versions are incorrect. These are all set correctly in my config.
What am I doing wrong here?
{slug}
, sometimesnews/{slug}
. I never put{locale}
in if that's what you're curious about? I've seen that isn't recommended. – joe Feb 8 '17 at 9:15