3
votes

My problem is that I can not translate a date from English to Russian. I followed this guides:

  1. Internationalization & Localization CakePHP
  2. I18N shell

I wrote in AppController.php this code:

function beforeFilter() {
    parent::beforeFilter();
    setlocale(LC_ALL, "ru_RU.utf8");
    Configure::write('Config.language', 'rus');
    CakeSession::write('Config.language', 'rus');
}

I added a folder "Locale\rus\LC_MESSAGES" and place inside the file default.po. BTW i extracted all messages to the single file.

But in fact:

<?php echo $this->Time->timeAgoInWords($feedback['Feedback']['created']); ?> 

Did nothing.

<?php echo __d('default', $this->Time->timeAgoInWords($feedback['Feedback']['created']), true); ?>

Translates only string 'just now' to russian language, but other time formats still in English. Examples of translates from default.po you can see below:

success

#: Lib\Cake\Utility\CakeTime.php:842
#: Utility\CakeTime.php:842
msgid "just now"
msgstr "translate"

fail

#: Lib\Cake\Utility\CakeTime.php:829
#: Utility\CakeTime.php:829
msgid "%d week"
msgid_plural "%d weeks"
msgstr[0] "%d translate"
msgstr[1] "%d translate"

I can't understand what i'm doing wrong.

1
I'd recommend not putting all translations in one file - and using the localized repository (which doesn't at this time have a russian translation file - but you could create one =). from the code if the above translations exist it's not logical for them to be ignored - which could indicate the default.po file you have is malformed in some way.AD7six

1 Answers

0
votes

For translating CakePHP core strings like those in Lib\Cake\Utility folder you need to use a different translation domain. The default domain for your views would be 'default' but for CakePHP core strings it is 'cake'.

Instead of 'default.po' you need to provide 'cake.po'. Otherwise your translations will have no effect.