Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-21T08:34:35.453Z
Answers.LastActivityDate: 2014-07-21T08:34:35.453Z
Answers.UserDisplayName: Matt Wilcox
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-16T14:53:55.090Z
Answers.Text: Yep, looks like this:
  https://gist.github.com/MattWilcox/6dd0ac022d71c117d941#file-craftconfigtroubleshoot
  
  (oh man these comments are a PITA to format!)
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-16T16:40:59.083Z
Answers.Text: The first thing I'd try to do, is to remove that empty "non-locale" locale.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T07:50:09.227Z
Answers.Text: 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.
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T13:03:49.343Z
Answers.Text: @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.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-19T10:17:47.220Z
Answers.Text: 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.
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-16T14:38:06.010Z
Answers.LastActivityDate: 2014-07-16T14:38:06.010Z
Answers.UserDisplayName: carlcs
Body: <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>
  
Tags: <localization><url><navigation>
Title: How to persist locale in site navigation?
ThreadText: # 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:
  
  ```
  <ul>
      <li><a href="{{ url('news') }}" {% if craft.request.firstSegment == 'news' %}class="active"{% endif %}>News</a></li>
      <li><a href="{{ url('artists') }}">Artists</a></li>
  </ul>
  
  ```
  
  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](http://buildwithcraft.com/help/localization) 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/username_0/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**: @username_0 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.  
  
  ---
  
  