<p>I'm working on the language switcher and have it working. The only thing is I want it to pull from <code>group</code> <code>data-id=1</code> It's pulling from all sites because of the <code>i18n</code> to change the language name to it's native name.</p>

<p>I made a "disabled" group in Craft CMS 3 and put Russian in it and it shows up with <code>i18n</code>.  I had it working before by only the 2 letter abbreviation showed such as "de" instead of Deutsch and Russian didn't show.</p>

<pre><code>&lt;div class="language-menu" aria-labelledby="navbarDropdownMenuLink" id="language-menu"&gt;
{% set currentSite = craft.app.sites.currentSite %}
{% for siteInGroup in currentSite.getGroup.getSites() %}
   {% if siteInGroup.id == entry.siteId %}
      {% for locale in craft.i18n.getSiteLocales() %}
        &lt;a href="{{ entryForOtherSite.getUrl() }}"&gt;{{ locale.getDisplayName() }}&lt;/a&gt;
   {% else %}
      {% set entryForOtherSite = craft.entries.id(entry.id).site(siteInGroup).one() %}
        &lt;a href="{{ entryForOtherSite.getUrl() }}"&gt;{{ locale.getDisplayName(siteInGroup.language) }}&lt;/a&gt;
      {% endfor %}
   {% endif %}
{% endfor %}
&lt;/div&gt;
</code></pre>

<p>I figured it out:</p>

<pre><code>    {% set currentSite = craft.app.sites.currentSite %}
{% for siteInGroup in currentSite.getGroup.getSites() %}
   {% if siteInGroup.id == entry.siteId %}
        &lt;a href="{{ entryForOtherSite.getUrl() }}"&gt;{{ locale.getDisplayName() }}&lt;/a&gt;
   {% else %}
      {% set entryForOtherSite = craft.entries.id(entry.id).site(siteInGroup).one() %}
      {% set locale = craft.i18n.getLocaleById(siteInGroup.language) %}
        &lt;a href="{{ entryForOtherSite.getUrl() }}"&gt;{{ locale.getDisplayName(siteInGroup.language) }}&lt;/a&gt;
   {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2018-11-08T20:17:55.473Z
Sorry, but I'm not following... what's the issue you're having and what's the behavior you're looking for?  What is `group` and `data-id=1`?
Brad Bell
CC BY-SA 4.0
2018-11-08T20:37:23.077Z
I have two site groups (disabled and live) and just want to show the live group on the language menu.
Nick
CC BY-SA 4.0
2018-11-08T21:33:13.497Z
I figured it out
Nick
CC BY-SA 4.0
2018-11-08T21:42:35.573Z
Awesome! Would you mind adding your solution as an official answer?
Brad Bell
<craft3><language>
Craft 3 Launguage Switcher by certain group
# Craft 3 Launguage Switcher by certain group

(Asked by: username_0 on 2018-11-08)

I'm working on the language switcher and have it working. The only thing is I want it to pull from group data-id=1 It's pulling from all sites because of the i18n to change the language name to it's native name.
I made a "disabled" group in Craft CMS 3 and put Russian in it and it shows up with i18n.  I had it working before by only the 2 letter abbreviation showed such as "de" instead of Deutsch and Russian didn't show.

{% set currentSite = craft.app.sites.currentSite %}
{% for siteInGroup in currentSite.getGroup.getSites() %}
   {% if siteInGroup.id == entry.siteId %}
      {% for locale in craft.i18n.getSiteLocales() %}
        {{ locale.getDisplayName() }}
   {% else %}
      {% set entryForOtherSite = craft.entries.id(entry.id).site(siteInGroup).one() %}
        {{ locale.getDisplayName(siteInGroup.language) }}
      {% endfor %}
   {% endif %}
{% endfor %}


I figured it out:
    {% set currentSite = craft.app.sites.currentSite %}
{% for siteInGroup in currentSite.getGroup.getSites() %}
   {% if siteInGroup.id == entry.siteId %}
        {{ locale.getDisplayName() }}
   {% else %}
      {% set entryForOtherSite = craft.entries.id(entry.id).site(siteInGroup).one() %}
      {% set locale = craft.i18n.getLocaleById(siteInGroup.language) %}
        {{ locale.getDisplayName(siteInGroup.language) }}
   {% endif %}
{% endfor %}

**Tags:** craft3, language

> **Comments:**
> **username_1**: Sorry, but I'm not following... what's the issue you're having and what's the behavior you're looking for?  What is `group` and `data-id=1`?  
> **username_0**: I have two site groups (disabled and live) and just want to show the live group on the language menu.  
> **username_0**: I figured it out  
> **username_1**: Awesome! Would you mind adding your solution as an official answer?  

---

## 0 answers

