Closed gpoehl closed 8 years ago
As a consequence of the situation described above the following error occurs as well when rbac\DBManager::checkAccessRecursive
is checking permission: rbac_admin
yii\i18n\PhpMessageSource::loadMessages
The message file for category 'yii' does not exist: D:\WebRoot\yii-advanced\vendor\yiisoft\yii2/messages/en-En/yii.php Fallback file does not exist as well: D:\WebRoot\yii-advanced\vendor\yiisoft\yii2/messages/en/yii.php
This is expected.
Setup of Application::sourceLanguage
does not affect any already loaded MessageSource
instances as they have thier own sourceLanguage
, which is filled up as copy of the one from application during message source creation.
If you wish sourceLanguage
to be changed for any message source you should change it manually there.
Note: there is no sense of changing Application::sourceLanguage
during aplication running, as it is "the language that the application is written in", which is unlikely to vary on any conditions.
@klimov-paul, thank's for your explanation. But I don't follow your arguments.
1) There might be many reasons to develop an application using more than one language. Even if you use only one language there might be external sources written in another language. Yii itself has options for modules and widgets to set the source language. So different languages between modules and widgets are already supported.
2) Documentation says clearly that the current application language is used for translations : Yii tries to load an appropriate translation according to the current application language from one of the message sources defined in the i18n application component. If you don't want to change the current behavior docs need to be adjusted.
3) MessageSource
is used in many classes so that I don't know right out of the box what needs to be done to get the expected translations. I expected.
So some more help would be greatly appreciated.
4) Breadcrumbs don't find category 'yii' when sourceLanguage is changed. For details see issue https://github.com/yiisoft/yii2/issues/8131.
if your source language varies among different sources you can configure it per message source: http://www.yiiframework.com/doc-2.0/yii-i18n-messagesource.html#$sourceLanguage-detail
@cebe, that's a very clever solution. Thank's a lot for pointing in the right direction. Without your help I wouldn't got it. Might be helpful for others to adjust the documentation. See my above comment (number 2) which suggests to change the application language on the fly. Instead you'd better work with different categories related to different sorce languages.
Once the yii:t('app','something') has been called changing the sourceLanguage has no effect for following translations.
To verify this you might use this example: There is an app.php file in each of the folders de, en and it under frontend\messages with a content like this:
That's the view file to play around: