title: Internationalization and Localization in CakePHP 2.1
body: <p>I am building a dual language app in CakePHP 2.1.x because of the great reviews of Cake's "built-in" localization features. However, I am wrestling with getting this powerful feature to work.</p>
  
  <p>I know that this topic has been tackled for previous versions of Cake (<a href="http://www.cakephparticles.com/cakephp-internationalization-and-localization" rel="nofollow noreferrer">here</a>, <a href="http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization" rel="nofollow noreferrer">here</a>,  <a href="https://stackoverflow.com/questions/2661275/using-localization-in-cakephp">here</a>, and <a href="http://bakery.cakephp.org/articles/p0windah/2007/09/12/p28n-the-top-to-bottom-persistent-internationalization-tutorial" rel="nofollow noreferrer">here</a>), but it hasn't been solved for Cake 2.x. I am also referencing these articles in the cookbook (yes, I've read the manual): </p>
  
  <ul>
  <li><a href="http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html" rel="nofollow noreferrer">http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html</a></li>
  <li><a href="http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html" rel="nofollow noreferrer">http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html</a></li>
  </ul>
  
  <p>Couple of things -- I do not want to do separate subdomains for each language. Instead, I prefer URL based language switching with the click of a button (in this case, a flag icon). The site will be actively maintained, so the content needs to update dynamically. Asking the client to maintain two separate sites/databases is out of the question.</p>
  
  <p>I have Translate behavior set up for my PostModel, but I can't tell if it's working. I also initialized I18n by running <code>I18n</code> in the console, have confirmed the database tables exist, have set up my .po files, and have wrapped all my content in <code>__()</code>. However, when I change the default language in my browser to French, the site remains in English. </p>
  
  <p>I've tried the P28n Component, but I think it's outdated for Cake 2.x. I also tried URL-based language switching based on this <a href="http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization" rel="nofollow noreferrer">nuts-and-bolts-of-cakephp article</a>, but apparently it's incompatible with the new CakePHP API.</p>
  
  <p>Can anyone point me in the direction of a tutorial or instructions that work with CakePHP 2.x? One not already referenced here?</p>
  
  <p><strong>Update:</strong> I found this article: <a href="http://www.localizingjapan.com/blog/2011/11/10/localizing-a-cakephp-application/comment-page-1/#comment-7467" rel="nofollow noreferrer">http://www.localizingjapan.com/blog/2011/11/10/localizing-a-cakephp-application/comment-page-1/#comment-7467</a>. Does anyone know where you place the code for <code>CakeSession::write('Config.language', 'fre');</code> and <code>setlocale("LC_ALL", "fr_FR.utf8");</code>?</p>