setono / sylius-fragment-translation-plugin
自动翻译文本片段
v0.3.2
2022-02-28 08:53 UTC
Requires
- php: >=7.4
- doctrine/orm: ^2.7
- doctrine/persistence: ^1.3 || ^2.0
- setono/doctrine-orm-batcher: ^0.6
- setono/doctrine-orm-batcher-bundle: ^0.3.1
- sylius/resource-bundle: ^1.6
- symfony/config: ^4.4 || ^5.0
- symfony/console: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/form: ^4.4 || ^5.0
- symfony/messenger: ^4.4 || ^5.0
- symfony/property-access: ^4.4 || ^5.0
- webmozart/assert: ^1.9
Requires (Dev)
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.2
- phpspec/phpspec: ^7.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- psalm/plugin-symfony: ^2.4
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.1.1
- setono/sylius-behat-pack: ^0.2.1
- sylius/sylius: ~1.7.0
- symfony/debug-bundle: ^5.1
- symfony/dotenv: ^5.2
- symfony/intl: ^4.4 || ^5.0
- symfony/web-profiler-bundle: ^5.0
- weirdan/doctrine-psalm-plugin: ^1.0
This package is auto-updated.
Last update: 2024-09-15 19:20:53 UTC
README
自动翻译文本片段。
安装
步骤 1: 安装依赖项
此插件使用了 Doctrine ORM Batcher 包。请先安装它。
步骤 2: 下载插件
打开命令行控制台,进入项目目录,并执行以下命令以下载此插件的最新稳定版本
$ composer require setono/sylius-fragment-translation-plugin
此命令要求您全局安装了 Composer,具体请参阅 Composer 文档的 安装章节。
步骤 3: 启用插件
然后,通过将其添加到项目 config/bundles.php
文件中注册的插件/包列表中(在 SyliusGridBundle
之前)来启用该插件。
<?php $bundles = [ Setono\SyliusFragmentTranslationPlugin\SetonoSyliusFragmentTranslationPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], ];
步骤 4: 配置插件
首先导入通用配置
# config/packages/_sylius.yaml imports: # ... - { resource: "@SetonoSyliusFragmentTranslationPlugin/Resources/config/app/config.yaml" } # ...
然后配置您想进行 '片段翻译' 的资源
# config/packages/setono_sylius_fragment_translation.yaml setono_sylius_fragment_translation: resource_translations: - name: sylius.product properties: - name
步骤 5: 导入路由
# config/routes/setono_sylius_fragment_translation.yaml setono_sylius_fragment_translation: resource: "@SetonoSyliusFragmentTranslationPlugin/Resources/config/routing.yaml"
步骤 6: 更新您的数据库模式
$ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate
步骤 7: 使用异步传输(可选,但推荐)
此插件中的所有命令都将扩展 CommandInterface。因此,您可以轻松地将所有命令路由到您的 消息传递器配置。
# config/packages/messenger.yaml framework: messenger: routing: # Route all command messages to the async transport # This presumes that you have already set up an 'async' transport # See docs on how to setup a transport like that: https://symfony.com.cn/doc/current/messenger.html#transports-async-queued-messages 'Setono\SyliusFragmentTranslationPlugin\Message\Command\CommandInterface': async
使用方法
步骤 1: 创建片段翻译
访问 /admin/fragment-translations/new
并尝试输入
步骤 2: 运行 CLI 命令
$ php bin/console setono:sylius-fragment-translation:translate
如果查看您的数据库,现在应该有包含 Sticker
的产品名称的丹麦语翻译,并且名称应该已经翻译成 Klistermærke
。
步骤 3: 使用异步传输(推荐)
# config/packages/messenger.yaml framework: messenger: routing: # Route all command messages to the async transport # This presumes that you have already set up an 'async' transport 'Setono\SyliusFragmentTranslationPlugin\Message\Command\CommandInterface': async