PHP code example of blendbyte / laravel-crowdin-sync

1. Go to this page and download the library: Download blendbyte/laravel-crowdin-sync 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/ */

    

blendbyte / laravel-crowdin-sync example snippets


return [
    // Crowdin Access Token for the API
    'api_key' => env('CROWDIN_API_KEY'),

    // Project ID for Translation Files (must be "File-based project")
    'project_id_files' => env('CROWDIN_PROJECT_ID_FILES'),

    // Project ID for Content Translations (must be "String-based project")
    'project_id_content' => env('CROWDIN_PROJECT_ID_CONTENT'),

    // File Update Option, choose one of clear_translations_and_approvals, keep_translations, keep_translations_and_approvals
    'file_update_options' => env('CROWDIN_FILE_UPDATE_OPTIONS', 'clear_translations_and_approvals'),

    // Only export approved translations for translation files
    'file_export_approved_only' => env('CROWDIN_FILE_EXPORT_APPROVED_ONLY', true),

    // Content branch ID
    'content_branch_id' => env('CROWDIN_CONTENT_BRANCH_ID', -1),

    // Only apply approved translations to content translations
    'content_approved_only' => env('CROWDIN_CONTENT_APPROVED_ONLY', false),
];

LaravelCrowdinSync::make()->syncFiles(source_path: 'lang/', crowdin_path: 'laravel/');
LaravelCrowdinSync::make()->uploadFiles(source_path: 'lang/', crowdin_path: 'laravel/');
LaravelCrowdinSync::make()->downloadFiles(source_path: 'lang/', crowdin_path: 'laravel/');
LaravelCrowdinSync::make()->syncContent(\App\Models\Page::class);
LaravelCrowdinSync::make()->uploadContent(\App\Models\Page::class);
LaravelCrowdinSync::make()->downloadContent(\App\Models\Page::class);
bash
php artisan vendor:publish --tag="crowdin-sync-config"