guave/deepl-bundle

Adds support for deepl.com translation to contao dca input fields

Installs: 1 638

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 4

Forks: 0

Open Issues: 3

Type:contao-bundle

1.0.19 2024-10-11 09:46 UTC

This package is auto-updated.

Last update: 2024-11-14 15:07:38 UTC


README

Adds support for deepl translation API in DCA input fields.

Also supports Multilingual Data Container

Install

Install Contao bundle

composer require guave/deepl-bundle

Add deepl API key to .env

DEEPL_API_KEY=''

Install assets

if you use web as the document root, pass it as an argument

php vendor/bin/contao-console assets:install

Configuration

guave_deepl:
  enabled: true
  freeApi: true
  defaultLanguage: de
  tables:
    tl_content:
      fields:
        - title
        - text
      multiColumnFields:
        category_grid:
          fields:
            - title
            - text

Register Custom ActiveLanguageResolver

Register it with the tag deepl.resolver

# services.yml
services:
  # ...

  App\Resolver\ActiveLanguageByProductLanguageResolver:
    public: true
    tags:
      - { name: 'deepl.resolver', priority: 50 }
# src/Resolver/ActiveLanguageByProductLanguageResolver.php
<?php

namespace App\Resolver;

use Contao\DataContainer;
use Guave\DeeplBundle\Resolver\ActiveLanguageResolverInterface;

class ActiveLanguageByProductLanguageResolver implements ActiveLanguageResolverInterface
{
    public function supports(DataContainer $dataContainer): bool
    {
        // TODO: Implement supports() method.
    }

    public function resolve(DataContainer $dataContainer): ?string
    {
        // TODO: Implement resolve() method.
    }}
}