inside my views to display text in several languag...">

CakePHP 2.1.po files / translation does not work

I use <?php echo __("this is my string"); ?>inside my views to display text in several languages. I created a directory of .po files for German:

=> app / Locale / ger / LC_MESSAGES / default.po

msgstr "this is my line"

msgstr "dying from meine zeichenkette"

When I add Configure::write('Config.language','ger');beforeController.php to my function AppController.php, the text still remains “this is my line”. Even if I create .po for English with another msgstr, the text remains the same.

Do I need to change a specific parameter to activate the translation?


I have a problem: I added Configure::write('Config.language','eng');in core.php to set my default language, but now I can’t change the value even if I try to override it in AppController.php beforeFilter with:

Configure::write('Config.language', 'deu'); //'de' also doesn't work
CakeSession::write('Config.language', 'deu'); //'de' also doesn't work

If I changed the value in core.php, it works fine, but after installing in core.php I can’t change it.

resolved: ah, I forgot to add parent::beforeFilter();all the controllers to the beforeFilter function.


Additional Information:

  • If you want to define the default language (and usually will), add Configure::write('Config.language', 'eng');in core.php
+5
source share
2 answers

You can look at the file lib / Cake / I18n / L10n.php to learn how to call each language.

for German:

Configure::write('Config.language','de');

= > app/Locale/deu/LC_MESSAGES/default.po

+8

"deu" "ger"

CakePHP (T) http://www.loc.gov/standards/iso639-2/php/code_list.php, CakePHP 1.3 :

ISO 639-2, , (en_US, en_GB ..) ) , .

ISO 639-2 |  ISO 639-1 | English name | French name | German name |
Code      |  Code      | of Language  | of Language | of Language |
-------------------------------------------------------------------
ger (B)   |            |              |             |             |
deu (T)   |  de        | German       | allemand    | Deutsch     |
+6

All Articles