Answer the question
In order to leave comments, you need to log in
How to set Yii2 component messages?
Hello.
Some component for Yii2, which is installed via Composer.
How to correctly configure the component code so that the component has its own messages (on errors and just messages), and at the same time, after installing it through composer in the application, the messages can be overridden?
What settings should be in the application for such a case?
Example. Let's say the component's messages are located in the vendor/package/src/messages directory. Somewhere in the component's code, a message is called:
throw new \ErrorException(\Yii:t('component', 'absolutely_peace_death'));
Answer the question
In order to leave comments, you need to log in
If the file exists
So, you create a child class in app/components. and call it. work your magic in it.
magic is bad) it is not clear how it works) it is necessary that it be as transparent as possible
for yourself to find such a solution (you never know, maybe it will come in handy for someone), which does not seem to violate the behavior of the framework:
works through normal Y::t() behavior without any extra standard functions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question