In Cakephp 2, I was using this repo for cake.po translations. But it seems like it isn't not updated for Cakephp 3. So I runned i18n shell as noted here and created cake.pot file. Then I made some of translations and added cake.po files into the folder src\Locale\.
When the msgstr part is empty, timeAgoInWords shows English words, if translation found, cakephp shows translated version.
But this doesn't work for Arabic language. Other languages works well.
In cakephp 3 while making a timeAgoInWords like this:
$string = $this->Time->timeAgoInWords(1338659672, array('end' => '+10 year'));
I get this error: Error: [Aura\Intl\Exception\CannotInstantiateFormatter] msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR
Error stack:
Error: [Aura\Intl\Exception\CannotInstantiateFormatter] msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR
Request URL: /ar/tools/
Stack Trace:
#0 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/I18n/Formatter/IcuFormatter.php(71): Cake\I18n\Formatter\IcuFormatter->_formatMessage('ar', NULL, Array)
#1 /var/www/vhosts/example.com/httpdocs/app/vendor/aura/intl/src/Aura/Intl/Translator.php(142): Cake\I18n\Formatter\IcuFormatter->format('ar', Array, Array)
#2 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/I18n/functions.php(110): Aura\Intl\Translator->translate('{0} years', Array)
#3 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/I18n/Time.php(384): __dn('cake', '{0} year', '{0} years', 3, 3)
#4 /var/www/vhosts/example.com/httpdocs/app/src/Template/Tools/index.ctp(62): Cake\I18n\Time->timeAgoInWords(Array)
#5 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/View/View.php(833): include('/var/www/vhosts...')
#6 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/View/View.php(793): Cake\View\View->_evaluate('/var/www/vhosts...', Array)
#7 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/View/View.php(464): Cake\View\View->_render('/var/www/vhosts...')
#8 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/Controller/Controller.php(582): Cake\View\View->render(NULL, NULL)
#9 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(120): Cake\Controller\Controller->render()
#10 /var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(87): Cake\Routing\Dispatcher->_invoke(Object(App\Controller\ToolsController))
#11 /var/www/vhosts/example.com/httpdocs/app/webroot/index.php(37): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#12 {main}
Notice: Notice (8): Undefined offset: 3 in [/var/www/vhosts/example.com/httpdocs/app/vendor/cakephp/cakephp/src/I18n/Formatter/IcuFormatter.php, line 68]
Trace:
Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 138
Cake\I18n\Formatter\IcuFormatter::format() - CORE/src/I18n/Formatter/IcuFormatter.php, line 68
Aura\Intl\Translator::translate() - ROOT/vendor/aura/intl/src/Aura/Intl/Translator.php, line 142
__dn - CORE/src/I18n/functions.php, line 110
Cake\I18n\Time::timeAgoInWords() - CORE/src/I18n/Time.php, line 384
include - APP/Template/Tools/index.ctp, line 62
Cake\View\View::_evaluate() - CORE/src/View/View.php, line 833
Cake\View\View::_render() - CORE/src/View/View.php, line 793
Cake\View\View::render() - CORE/src/View/View.php, line 464
Cake\Controller\Controller::render() - CORE/src/Controller/Controller.php, line 582
Cake\Routing\Dispatcher::_invoke() - CORE/src/Routing/Dispatcher.php, line 120
Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 87
[main] - ROOT/webroot/index.php, line 37
Edit: I get very similar error for Russian language. When I remove src\Locale\ru\cake.po file, I get U_ILLEGAL_ARGUMENT_ERROR again. Note that Russian has 3 plural form, while English and other languages have 2 plural forms.