PHP code example of cargofy / laravel-ai-i18n

1. Go to this page and download the library: Download cargofy/laravel-ai-i18n 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/ */

    

cargofy / laravel-ai-i18n example snippets


return [
    // The driver to use for translation
    'driver' => env('AI_TRANSLATION_DRIVER', 'chatgpt'),

    // Available translation services
    'services' => [
        // ChatGPT translation service
        'chatgpt' => [
            'api_key' => env('OPENAI_API_KEY'),
            'model' => env('OPENAI_MODEL', 'gpt-4o'),
            'temperature' => env('OPENAI_TEMPERATURE', 0.3),
        ],
        
        // You can add more services here in the future
        // 'google' => [
        //     'api_key' => env('GOOGLE_TRANSLATE_API_KEY'),
        // ],
    ],

    // Language settings
    'languages' => [
        // The source language code (ISO 639-1)
        'source' => 'en',
        
        // Target languages to translate to (array of ISO 639-1 codes)
        'targets' => ['uk', 'de', 'fr', 'es'],
    ],

    // Paths configuration
    'paths' => [
        // Directories containing language files to translate
        'lang_dirs' => [
            'lang',
            'resources/lang',
        ],
        
        // File patterns to 
bash
php artisan vendor:publish --tag="laravel-ai-i18n-config"
bash
php artisan vendor:publish --tag="laravel-ai-i18n-provider"
bash
php artisan translate:ai
bash
php artisan translate:ai --source=en --target=uk,de,fr
bash
php artisan translate:ai --force