<p>I found the problem. We use 'en' and 'gb' in the website's URLs (<a href="http://website.dev/en/whatever" rel="nofollow">http://website.dev/en/whatever</a> and <a href="http://website.dev/cy/whatever" rel="nofollow">http://website.dev/cy/whatever</a>), and I'd mis-understood what Craft was looking for in the /craft/config/general.php setting - I'd put the 'site_url' values as those two-character codes - that's wrong.</p>

<p>In short, even though my URLs are en and cy, because the Locale values are actually en_gb and cy_gb, I needed to set the site_url array to those values (the URL has nothing to do with anything, which was what I'd mis-understood).</p>

CC BY-SA 3.0
2014-07-21T08:34:35.453Z
2014-07-21T08:34:35.453Z
Matt Wilcox
<p>Did you <a href="http://buildwithcraft.com/help/localization" rel="nofollow">configure siteUrl</a> in <code>general.php</code>, so Craft knows what the base URL is for your entries?</p>

<pre><code>return array(
    'siteUrl' =&gt; array(
        'en' =&gt; 'http://craft.dev/en/',
        'cy' =&gt; 'http://craft.dev/cy/',
    ),
);
</code></pre>

CC BY-SA 3.0
2014-07-16T14:53:55.090Z
Yep, looks like this:
https://gist.github.com/MattWilcox/6dd0ac022d71c117d941#file-craftconfigtroubleshoot

(oh man these comments are a PITA to format!)
Matt Wilcox
CC BY-SA 3.0
2014-07-16T16:40:59.083Z
The first thing I'd try to do, is to remove that empty "non-locale" locale.
carlcs
CC BY-SA 3.0
2014-07-17T07:50:09.227Z
I've removed that, no change. It's actually all links on the pages that are not using the correct locale prefix. It's odd; the page content itself is loading the correct locale, the links are not reflecting the correct locale.
Matt Wilcox
CC BY-SA 3.0
2014-07-17T13:03:49.343Z
@Matt I found that there is not `cy.php` in `framework/i18n/data`, maybe that's the problem? But it probably shouldn't as this only contains the date and time translations. Try to simplify the `general.php` to the absolute minimum, check your "en" and "cy" `index.php` files and the sections' slug settings in the CP. Other then that, I've no clue what could be going wrong.
carlcs
CC BY-SA 3.0
2014-07-19T10:17:47.220Z
I'd added the Welsh language files from the Yii library myself (though they're now included by default). I'll have to dig into this further on Monday. It doesn't look like anything is misconfigured, but I'll take your advice on stripping back. Thanks for the help.
Matt Wilcox
CC BY-SA 3.0
2014-07-16T14:38:06.010Z
2014-07-16T14:38:06.010Z
carlcs
<p>I've got a bi-lingual site running nicely, /en/news/news-item displays the English version and /cy/news/news-item displays the Welsh version. Great!</p>

<p>I can't figure out how to get the URLs for the main site navigation to respect the currently used locale though. For example;</p>

<p>If I'm on the page: <a href="http://craft.dev/cy/news/news-title" rel="nofollow">http://craft.dev/cy/news/news-title</a> the main site navigation should list 'news' and 'artist' with a /cy preceding the URL (/cy/news and /cy/artists). Instead it's spitting out /en/news and /en/artists.</p>

<p>The code I'm using to get the URLs for the navigation is: </p>

<pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;a href="{{ url('news') }}" {% if craft.request.firstSegment == 'news' %}class="active"{% endif %}&gt;News&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="{{ url('artists') }}"&gt;Artists&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>What am I doing wrong?</p>

<localization><url><navigation>
How to persist locale in site navigation?
# How to persist locale in site navigation?

(Asked by: username_0 on 2014-07-16)

I've got a bi-lingual site running nicely, /en/news/news-item displays the English version and /cy/news/news-item displays the Welsh version. Great!
I can't figure out how to get the URLs for the main site navigation to respect the currently used locale though. For example;
If I'm on the page: http://craft.dev/cy/news/news-title the main site navigation should list 'news' and 'artist' with a /cy preceding the URL (/cy/news and /cy/artists). Instead it's spitting out /en/news and /en/artists.
The code I'm using to get the URLs for the navigation is: 

    News
    Artists


What am I doing wrong?

**Tags:** localization, url, navigation


---

## 2 answers

### Answer by username_0 on 2014-07-21. Score: 1 | Accepted answer

I found the problem. We use 'en' and 'gb' in the website's URLs (<http://website.dev/en/whatever> and <http://website.dev/cy/whatever>), and I'd mis-understood what Craft was looking for in the /craft/config/general.php setting - I'd put the 'site\_url' values as those two-character codes - that's wrong.

In short, even though my URLs are en and cy, because the Locale values are actually en\_gb and cy\_gb, I needed to set the site\_url array to those values (the URL has nothing to do with anything, which was what I'd mis-understood).


---

### Answer by username_1 on 2014-07-16. Score: 3

Did you configure siteUrl in general.php, so Craft knows what the base URL is for your entries?
return array(
    'siteUrl' => array(
        'en' => 'http://craft.dev/en/',
        'cy' => 'http://craft.dev/cy/',
    ),
);

> **Comments:**
> **username_0**: Yep, looks like this: https://gist.github.com/MattWilcox/6dd0ac022d71c117d941#file-craftconfigtroubleshoot  (oh man these comments are a PITA to format!)  
> **username_1**: The first thing I'd try to do, is to remove that empty "non-locale" locale.  
> **username_0**: I've removed that, no change. It's actually all links on the pages that are not using the correct locale prefix. It's odd; the page content itself is loading the correct locale, the links are not reflecting the correct locale.  
> **username_1**: @Matt I found that there is not `cy.php` in `framework/i18n/data`, maybe that's the problem? But it probably shouldn't as this only contains the date and time translations. Try to simplify the `general.php` to the absolute minimum, check your "en" and "cy" `index.php` files and the sections' slug settings in the CP. Other then that, I've no clue what could be going wrong.  
> **username_0**: I'd added the Welsh language files from the Yii library myself (though they're now included by default). I'll have to dig into this further on Monday. It doesn't look like anything is misconfigured, but I'll take your advice on stripping back. Thanks for the help.  

---

