Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP 2.1 .po files / translation not working
    text
    copied!<p>I use <code>&lt;?php echo __("this is my string"); ?&gt;</code> inside my views to display text in multiple languages. I created a .po-file directory for german:</p> <p>=> app/Locale/ger/LC_MESSAGES/default.po</p> <blockquote> <p>msgid "this is my string" </p> <p>msgstr "dies ist meine zeichenkette"</p> </blockquote> <p>When I add <code>Configure::write('Config.language','ger');</code> to my AppController.php beforeFilter function the text still remains "this is my string". Even if I create a .po for english with a different msgstr the text still remains the same.</p> <p>Do I have to change a specific setting to activate the translation?</p> <hr> <p>I have a follow up problem: I added <code>Configure::write('Config.language','eng');</code> to <strong>core.php</strong> to set my default language but now I can't change the value, even if I try to override it in <strong>AppController.php</strong> beforeFilter with:</p> <pre><code>Configure::write('Config.language', 'deu'); //'de' also doesn't work CakeSession::write('Config.language', 'deu'); //'de' also doesn't work </code></pre> <p>If I change the value in core.php it works perfectly fine but once set in core.php I cant change it.</p> <p><strong>solved:</strong> ah, I forgot to add <code>parent::beforeFilter();</code> inside the beforeFilter function of all the controllers.</p> <hr> <p><strong>Additional information:</strong></p> <ul> <li>If you want to define a default language (and you usually will), add <code>Configure::write('Config.language', 'eng');</code> to the <strong>core.php</strong></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload