Skip to content
Advertisement

yii2 extract messages to db

I’m using trntv/Yii2-starter-kit. How can I extract messages to DB? My config:

JavaScript

My I18N file:

JavaScript

I tryed:

JavaScript

And php yii message But always it writes all messages to files: vendor/yiisoft/yii2/messages. How can I export messages to DB? Has anyone help?

Advertisement

Answer

You need to use the following as per CONSOLE-DOCS there is a ExtendedMessageControler class. This controller extends default MessageController to provide some useful actions:

  • To migrate messages between different message sources run the common like below

    php console/yii message/migrate @common/config/messages/php.php @common/config/messages/db.php

Which means you should have a file inside the @common/confiog/messages/ folder with the name db.php that will be used to create the message and source_message tables the contents of the file should be

JavaScript

and the messages source directory will be determined by the php.php file inside the @common/config/messages directory that contains the following

JavaScript

You just need to run the migration command and the tables will be created and the messages will be exported to the respective tables.

for more details see the SOURCE for the actionMigrate().

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement