setono / sylius-fragment-translation-plugin
Will translate fragments of text automatically
Installs: 15 761
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 2
Type:sylius-plugin
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-12-15 19:49:16 UTC
README
Will translate fragments of text automatically.
Installation
Step 1: Install dependencies
This plugin uses the Doctrine ORM Batcher bundle. Install that first.
Step 2: Download the plugin
Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:
$ composer require setono/sylius-fragment-translation-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 3: Enable the plugin
Then, enable the plugin by adding it to the list of registered plugins/bundles
in config/bundles.php
file of your project before (!) SyliusGridBundle
:
<?php $bundles = [ Setono\SyliusFragmentTranslationPlugin\SetonoSyliusFragmentTranslationPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], ];
Step 4: Configure plugin
First import the general configuration:
# config/packages/_sylius.yaml imports: # ... - { resource: "@SetonoSyliusFragmentTranslationPlugin/Resources/config/app/config.yaml" } # ...
Then configure what resources you want to 'fragment translate':
# config/packages/setono_sylius_fragment_translation.yaml setono_sylius_fragment_translation: resource_translations: - name: sylius.product properties: - name
Step 5: Import routing
# config/routes/setono_sylius_fragment_translation.yaml setono_sylius_fragment_translation: resource: "@SetonoSyliusFragmentTranslationPlugin/Resources/config/routing.yaml"
Step 6: Update your database schema
$ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate
Step 7: Using asynchronous transport (optional, but recommended)
All commands in this plugin will extend the CommandInterface. Therefore you can route all commands easily by adding this to your Messenger config:
# 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/doc/current/messenger.html#transports-async-queued-messages 'Setono\SyliusFragmentTranslationPlugin\Message\Command\CommandInterface': async
Usage
Step 1: Create a fragment translation
Go to /admin/fragment-translations/new
and try to input:
Step 2: Run CLI command
$ php bin/console setono:sylius-fragment-translation:translate
If you look in your database you should now have Danish translations for the products with names containing Sticker
and the names should have been translated into Klistermærke
.
Step 3: Using asynchronous transport (recommended)
# 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