如何配置Yii2 i18n在数据库而不是文件中存储消息?

I find Yii2 documentation seriously lacking in documentation about i18n, particularly about using database instead of files for the translation messages.

I see documentation (EDIT: sorry, this was the link I meant) mentions the DbMessageSource class and somewhere else I found that the db tables should be named source_message and message but nowhere does it tell me the schema for those tables! And the yii message/extract command doesn't seem to auto-create the tables either.

How do I go about this?

Your documentation link is about a yii2 extension, you should read instead :

If you don't want to use migration and need SQL instead, files for all databases are in migrations directory.

https://github.com/yiisoft/yii2/tree/master/framework/i18n/migrations

For example, the schema for MySQL is :

CREATE TABLE `source_message`
(
   `id`          integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `category`    varchar(255),
   `message`     text
);

CREATE TABLE `message`
(
   `id`          integer NOT NULL,
   `language`    varchar(16) NOT NULL,
   `translation` text
);

ALTER TABLE `message` ADD CONSTRAINT `pk_message_id_language` PRIMARY KEY (`id`, `language`);
ALTER TABLE `message` ADD CONSTRAINT `fk_message_source_message` FOREIGN KEY (`id`) REFERENCES `source_message` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT;

The source_message table stores the messages to be translated, and the message table stores the translated messages. The name of these two tables can be customized by setting $sourceMessageTable and $messageTable, respectively.