6

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?

  • Have you setup the CRAFT_LOCALE correctly? buildwithcraft.com/help/localization – Victor In Jun 24 '14 at 11:16
  • 1
    Hadn't set it at all. That helps. – Low Jun 24 '14 at 11:29
  • Note to self: locale should be exact. en_us != en and nl_nl != nl. – Low Jun 24 '14 at 11:34
  • I'll add it as an answer for clarity. – Victor In Jun 24 '14 at 11:49
5

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');
}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.