Answers.Body: <p>If someone still is looking for an answer:</p>
  
  <pre><code>{% block locale__switch %}
      {# Loop through all of the site locales #}
      {% set otherLocales = craft.i18n.getSiteLocaleIds() %}
  
      {% for locale in otherLocales %}
  
          {# Check if site is category or Entry #}
          {% if category is defined %}
              {% set siteLocale = category.locale(locale) %}
          {% elseif entry is defined %}
              {% set siteLocale = craft.entries.id(entry.id).locale(locale).first %}
          {% endif %}
  
          {# Make sure that it's actually localized to this locale #}
          {% if siteLocale.locale == locale %}
  
              {# Output a link to it #}
              &lt;a href="{{ siteLocale.getUrl() }}" class="text-uppercase {% if craft.locale == siteLocale.locale %}active{% endif %}"&gt;{{ locale }}&lt;/a&gt;{% if not loop.last %} |{% endif %}
          {% else %}
  
              {# Output a link to the hompage #}
              &lt;a href="{{ craft.config.siteUrl[locale] }}"&gt;{{ locale }}&lt;/a&gt;
          {% endif %}
      {% endfor %}
  {% endblock %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-29T11:54:39.893Z
Answers.LastActivityDate: 2017-03-29T15:16:04.543Z
Answers.LastEditDate: 2017-03-29T15:16:04.543Z
Answers.UserDisplayName: Michael Moser
Body: <p>I am using Lindsey's <a href="https://github.com/lindseydiloreto/craft-languagelink" rel="nofollow">Language Link</a> plugin for my language switcher.</p>
  
  <p>Everything works well, as long as the url is not a category url.</p>
  
  <p>Here it is:</p>
  
  <pre><code>{% set element = (entry is defined ? entry : null) %}
  
  {% for locale in craft.i18n.getSiteLocales %}
      &lt;a href="{{ ll(locale.id, element) }}" class="dropdown-item"&gt;{{ locale.nativeName|capitalize }}&lt;/a&gt;
  {% endfor %}
  </code></pre>
  
  <p>Where can I tell Craft to used the translated slug in my language switcher?</p>
  
Tags: <categories><localization>
Title: Localization with categories
ThreadText: # Localization with categories
  
  (Asked by: username_0 on 2016-05-11)
  
  I am using Lindsey's [Language Link](https://github.com/lindseydiloreto/craft-languagelink) plugin for my language switcher.
  
  Everything works well, as long as the url is not a category url.
  
  Here it is:
  
  ```
  {% set element = (entry is defined ? entry : null) %}
  
  {% for locale in craft.i18n.getSiteLocales %}
      <a href="{{ ll(locale.id, element) }}" class="dropdown-item">{{ locale.nativeName|capitalize }}</a>
  {% endfor %}
  
  ```
  
  Where can I tell Craft to used the translated slug in my language switcher?
  
  **Tags:** categories, localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-29. Score: 1
  
  If someone still is looking for an answer:
  
  ```
  {% block locale__switch %}
      {# Loop through all of the site locales #}
      {% set otherLocales = craft.i18n.getSiteLocaleIds() %}
  
      {% for locale in otherLocales %}
  
          {# Check if site is category or Entry #}
          {% if category is defined %}
              {% set siteLocale = category.locale(locale) %}
          {% elseif entry is defined %}
              {% set siteLocale = craft.entries.id(entry.id).locale(locale).first %}
          {% endif %}
  
          {# Make sure that it's actually localized to this locale #}
          {% if siteLocale.locale == locale %}
  
              {# Output a link to it #}
              <a href="{{ siteLocale.getUrl() }}" class="text-uppercase {% if craft.locale == siteLocale.locale %}active{% endif %}">{{ locale }}</a>{% if not loop.last %} |{% endif %}
          {% else %}
  
              {# Output a link to the hompage #}
              <a href="{{ craft.config.siteUrl[locale] }}">{{ locale }}</a>
          {% endif %}
      {% endfor %}
  {% endblock %}
  
  ```
  
  
  ---
  
  