PHP code example of klickmanufaktur / statamic-translator

1. Go to this page and download the library: Download klickmanufaktur/statamic-translator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

klickmanufaktur / statamic-translator example snippets


return [
    App\Providers\AppServiceProvider::class,
    Klickmanufaktur\StatamicTranslator\ServiceProvider::class,
];

'source' => [
    'locale' => 'de',
    'name' => 'Deutsch',
    'label' => 'DE',
    'switcher_name' => 'German',
    'native_name' => 'Deutsch',
    'translation_notice' => [
        'title' => 'Hinweis zur automatisierten Übersetzung',
        'body' => 'Die ausgewählte Sprachfassung wird automatisiert erstellt. Trotz sorgfältiger technischer Umsetzung können Fehler, Auslassungen oder Abweichungen auftreten. Maßgeblich und rechtlich verbindlich ist ausschließlich die deutsche Originalfassung.',
        'cancel_label' => 'Abbrechen',
        'confirm_label' => 'Verstanden, fortfahren',
    ],
],

'locales' => [
    'en' => [
        'name' => 'English',
        'label' => 'EN',
        'switcher_name' => 'English',
        'native_name' => 'English',
        'deepl_target' => 'EN-US',
        'translation_notice' => [
            'title' => 'Notice about automatic translation',
            'body' => 'The selected language version is generated automatically. Despite careful technical implementation, errors, omissions or deviations may occur. Only the German original version is authoritative and legally binding.',
            'cancel_label' => 'Cancel',
            'confirm_label' => 'I understand, continue',
        ],
    ],
    'fr' => [
        'name' => 'Français',
        'label' => 'FR',
        'switcher_name' => 'French',
        'native_name' => 'français',
        'deepl_target' => 'FR',
        'translation_notice' => [
            'title' => 'Remarque concernant la traduction automatique',
            'body' => 'La version linguistique sélectionnée est générée automatiquement. Malgré une mise en œuvre technique soignée, des erreurs, omissions ou divergences peuvent survenir. Seule la version originale allemande fait foi et est juridiquement contraignante.',
            'cancel_label' => 'Annuler',
            'confirm_label' => 'J’ai compris, continuer',
        ],
    ],
],

'slugs' => [
    'preserve_segments' => [
        'service',
        'weiler',
        'haubersbronn',
    ],
    'overrides' => [
        'en' => [
            'lebenslagen' => 'lifesituations',
        ],
    ],
],

'protected_terms' => [
    'global' => [
        'Schorndorf',
        'Weiler',
        'Haubersbronn',
    ],
    'locales' => [
        'en' => [
            'Rems-Murr-Kreis',
        ],
    ],
],

'content' => [
    'ignored_keys' => [
        'address',
        'address_street',
        'address_city',
        'address_district',
        'street',
        'postal_code',
        'city',
        'ort',
        'district',
        'location',
    ],
    'ignored_text_patterns' => [
        '~\b\d{5}\s+[\pL][\pL\s.\'-]{1,80}\b~u',
        '~\b[\pL][\pL\s.\'-]*(?:straße|strasse|weg|platz|gasse|allee|ring)\s+\d+[a-z]?\b~iu',
    ],
],

'provider' => env('STATAMIC_TRANSLATOR_PROVIDER', 'custom'),

'providers' => [
    'custom' => [
        'class' => App\Translation\CustomTranslationProvider::class,
    ],
],
bash
php artisan vendor:publish --tag=statamic-translator-config
bash
php artisan translator:estimate --locale=en
php artisan translator:estimate --collection=pages --locale=en
bash
php artisan translator:urls --locale=en
php artisan translator:urls --collection=pages --locale=en
bash
php artisan translator:urls --locale=fr
bash
php artisan translator:warm --locale=en
php artisan translator:warm --locale=en --execute --max-chars=100000
antlers
<a href="{{ translator:url locale='en' }}">English</a>
antlers
<img alt="{{ translator:translate_attribute :text='image_alt' context='image-alt' }}">
<a aria-label="{{ translator:translate_attribute text='Bild vergrößern' context='image-zoom-label' }}">
antlers
<head>
    {{ seo }}
    {{ translator:alternate_links }}
</head>
bash
php artisan config:clear
php please static:clear