Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for DbMessageSource #13542

Merged
merged 3 commits into from
Aug 10, 2023
Merged

Conversation

brandonkelly
Copy link
Member

Description

Adds a setup/message-tables command, which sets the database up to use DbMessageSource for site translations.

Once run, the site translation category can be reconfigured via config/app.php like so:

use yii\helpers\UnsetArrayValue;
use yii\i18n\DbMessageSource;

return [
    'components' => [
        'i18n' => [
            'translations' => [
                'site' => [
                    'class' => DbMessageSource::class,
                    // DbMessageSource doesn't have a $basePath property,
                    // so remove it from the default config
                    'basePath' => new UnsetArrayValue(),
                ],
            ],
        ],
    ],
];

New site source messages and translations can then be added to the new source_message and message tables, and will be returned via Craft::t('site', 'source message') and the |t Twig filter.

@brandonkelly brandonkelly merged commit 9dd17cb into 4.5 Aug 10, 2023
@brandonkelly brandonkelly deleted the feature/i18n-message-tables branch August 10, 2023 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant