<p>Probably the <a href="http://buildwithcraft.com/docs/php-constants#craft-locale" rel="nofollow"><code>CRAFT_LOCALE</code></a> isn't set correctly. There is an in-depth <a href="http://buildwithcraft.com/help/localization" rel="nofollow">knowledge article here</a>.</p>

<p>To solve this, you could add a conditional to the <code>/public/index.php</code>:</p>

<pre class="lang-php prettyprint-override"><code>// Path to your craft/ folder
$craftPath = '../craft';

//Locale
if ( preg_match("/\/nl\//i", $_SERVER['REQUEST_URI']) ) { //Check if /nl/ is in the uri
    define('CRAFT_LOCALE', 'nl_nl');
}
else {
    define('CRAFT_LOCALE', 'en_us');
}
</code></pre>

CC BY-SA 3.0
2014-06-24T11:50:03.233Z
2014-06-24T12:27:43.380Z
2014-06-24T12:27:43.380Z
Victor
<p>My site has 2 locales: <code>en_us</code> and <code>nl_nl</code>. I also have a Structure section called Pages, which targets both locales. For each locale, the section has an Entry URL Format:</p>

<ul>
<li>en_us: <code>en/{slug}</code></li>
<li>nl_nl: <code>nl/{slug}</code></li>
</ul>

<p>The Entry Template setting for the section is <code>pages/_entry</code>, and there is a template there.</p>

<p>Now, for an entry with the slug <code>home</code> for both locales, the URI <code>nl/home</code> gives me the correct page, but <code>en/home</code> gives me a 404.</p>

<p>Is my setup wrong? Do I need to explicitly create <code>nl</code> and <code>en</code> template folders?</p>

CC BY-SA 3.0
2014-06-24T11:16:59.493Z
Have you setup the `CRAFT_LOCALE` correctly? http://buildwithcraft.com/help/localization
Victor
CC BY-SA 3.0
2014-06-24T11:29:11.330Z
Hadn't set it at all. That helps.
Low
CC BY-SA 3.0
2014-06-24T11:34:48.520Z
Note to self: locale should be exact. `en_us != en` and `nl_nl != nl`.
Low
CC BY-SA 3.0
2014-06-24T11:49:46.867Z
I'll add it as an answer for clarity.
Victor
<localization>
How do I get the right entry data based on locale and slug?
# How do I get the right entry data based on locale and slug?

(Asked by: username_0 on 2014-06-24)

My site has 2 locales: `en_us` and `nl_nl`. I also have a Structure section called Pages, which targets both locales. For each locale, the section has an Entry URL Format:

* en\_us: `en/{slug}`
* nl\_nl: `nl/{slug}`

The Entry Template setting for the section is `pages/_entry`, and there is a template there.

Now, for an entry with the slug `home` for both locales, the URI `nl/home` gives me the correct page, but `en/home` gives me a 404.

Is my setup wrong? Do I need to explicitly create `nl` and `en` template folders?

**Tags:** localization
> **Comments:**
> **username_1**: Have you setup the `CRAFT_LOCALE` correctly? http://buildwithcraft.com/help/localization  
> **username_0**: Hadn't set it at all. That helps.  
> **username_0**: Note to self: locale should be exact. `en_us != en` and `nl_nl != nl`.  
> **username_1**: I'll add it as an answer for clarity.  

---

## 1 answers

### Answer by username_1 on 2014-06-24. Score: 5 | Accepted answer

Probably the CRAFT_LOCALE isn't set correctly. There is an in-depth knowledge article here.
To solve this, you could add a conditional to the /public/index.php:
// Path to your craft/ folder
$craftPath = '../craft';

//Locale
if ( preg_match("/\/nl\//i", $_SERVER['REQUEST_URI']) ) { //Check if /nl/ is in the uri
    define('CRAFT_LOCALE', 'nl_nl');
}
else {
    define('CRAFT_LOCALE', 'en_us');
}


---

