<p>I probably don't fully understand what you're trying to acchieve, but to get to the index page of your current locale, you'd simply use <code>siteUrl()</code>.</p>

CC BY-SA 3.0
2015-02-21T17:22:18.157Z
2015-02-21T17:22:18.157Z
carlcs
<p>When calling this:</p>

<pre><code> {% set locale = craft.i18n.getCurrentLocale() %}
</code></pre>

<p><code>locale</code> is set to a full blown <a href="http://buildwithcraft.com/classreference/models/LocaleModel" rel="nofollow">LocaleModel</a> object.</p>

<p>What you're probably looking for is its <a href="http://buildwithcraft.com/classreference/models/LocaleModel#getId-detail" rel="nofollow">getId()</a> method.</p>

<pre><code>craft.config.siteUrl[locale-&gt;getId()]
</code></pre>

CC BY-SA 3.0
2015-02-22T09:14:53.273Z
Thanks Brad for your respond and time. To get a index link of a locale was simply to use `siteUrl()`.
Dominik Krulak
CC BY-SA 3.0
2015-02-21T17:20:39.143Z
2015-02-21T17:20:39.143Z
Brad Bell
<p>I have two menus.
One with countries, one with navigation.</p>

<p>Navigation menu must to have a index link of a active locale. 
So if I'm at example.com/uk/section and I go to navigation menu and click at index link, I get index of /uk</p>

<p>My countries menu code is:</p>

<pre><code>{% set locales = ['en', 'en_gb', 'sk'] %}
    {# Check if locale equals the requested page locale #}
    {% if locale == craft.locale %}
        {% set current = true %}
    {% else %}
        {% set current = false %}
    {% endif %}
    {% set locale = craft.i18n.getCurrentLocale() %}
      {% for locale in locales %}
         &lt;li&gt;
           &lt;a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}" class="{{ current ? 'uk-active'}}"&gt;{{ craft.i18n.getLocaleById(locale).name }}&lt;/a&gt;&lt;/li&gt;     
</code></pre>

<p>When I try to copy </p>

<pre><code>&lt;a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}" 
class="{{ current ? 'uk-active'}}"&gt;{{ craft.i18n.getLocaleById(locale).name }}&lt;/a&gt;
</code></pre>

<p>and put it to my navigation menu I get </p>

<pre><code>Internal Server Error    array_key_exists(): The first argument should be either a string or an integer
</code></pre>

<p>Is it fixable or any other way around?</p>

CC BY-SA 3.0
2015-02-21T17:30:47.370Z
Does `locale` in line 3 have a value? Code looks like there's missing pieces. See [this question](http://craftcms.stackexchange.com/q/877/125) for a working Language switch solution I use.
carlcs
<localization>
Get local's URL for index page
# Get local's URL for index page

(Asked by: username_0 on 2015-02-21)

I have two menus.
One with countries, one with navigation.
Navigation menu must to have a index link of a active locale. 
So if I'm at example.com/uk/section and I go to navigation menu and click at index link, I get index of /uk
My countries menu code is:
{% set locales = ['en', 'en_gb', 'sk'] %}
    {# Check if locale equals the requested page locale #}
    {% if locale == craft.locale %}
        {% set current = true %}
    {% else %}
        {% set current = false %}
    {% endif %}
    {% set locale = craft.i18n.getCurrentLocale() %}
      {% for locale in locales %}
         
           {{ craft.i18n.getLocaleById(locale).name }}     

When I try to copy 
{{ craft.i18n.getLocaleById(locale).name }}

and put it to my navigation menu I get 
Internal Server Error    array_key_exists(): The first argument should be either a string or an integer

Is it fixable or any other way around?

**Tags:** localization

> **Comments:**
> **username_1**: Does `locale` in line 3 have a value? Code looks like there's missing pieces. See [this question](http://craftcms.stackexchange.com/q/877/125) for a working Language switch solution I use.  

---

## 2 answers

### Answer by username_1 on 2015-02-21. Score: 3 | Accepted answer

I probably don't fully understand what you're trying to acchieve, but to get to the index page of your current locale, you'd simply use `siteUrl()`.


---

### Answer by username_2 on 2015-02-21. Score: 2

When calling this:
 {% set locale = craft.i18n.getCurrentLocale() %}

locale is set to a full blown LocaleModel object.
What you're probably looking for is its getId() method.
craft.config.siteUrl[locale->getId()]

> **Comments:**
> **username_0**: Thanks Brad for your respond and time. To get a index link of a locale was simply to use `siteUrl()`.  

---

