There are a few aspects of i18n that I haven’t been able to understand.
I was trying to figure out if it was possible to translate the strings defined in settings.php and loaded via Configure.
Consider this scenario:
I have a a custom settings defined as it follow
// in settings.php return [ 'Settings' => [ 'genders' => [ 'm' =>__d('settings', 'Male'), 'f' => __d('settings', 'Female'), ], 'salutations' => [ 'm' => 'Mr.', 'f' => 'Mrs.', ], ], ]
I use this settings to set the Gender field options when creating / editing a user.
Just for example:
echo $this->Form->control('email', ['required' => false]); echo $this->Form->control('gender', [ 'required' => false, 'options' => Configure::read('Settings.genders') ] ); echo $this->Form->control('first_name', ['required' => false]); echo $this->Form->control('last_name', ['required' => false]);
When i extract the translate strings from
/config i can see a
settings.pot file is created in
After that i proceed to create a translate file:
resources/locales/de/settings.po and clean the cake core cache with the command:
bin/cake cache clear _cake_core_
What did i expect?
I expect that by visiting the page
en/users/add the gender field has Male and Female as options, while visiting the page
de/users/add the options should be Männlich and Weiblich
What did i get?
de/users/add the options for gender are Male and Female
It seems that the same thing also happens for the validation messages defined in the Tables models.
Every other traslate string works fine (i mean the ones in the controllers or the views)
Anyone is facing the same problem?