PHP code example of be-interactive / laravel-translation-scanner

1. Go to this page and download the library: Download be-interactive/laravel-translation-scanner 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/ */

    

be-interactive / laravel-translation-scanner example snippets


\BeInteractive\TranslationScanner\Facades\TranslationScanner::laravel()
    ->filament()
    ->regex('/test/')
    // This stores all language lines
    ->store();

\BeInteractive\TranslationScanner\Facades\TranslationScanner::filament()->scanFiles();

\BeInteractive\TranslationScanner\TranslationScanner::laravel()
    ->store(deleteLinesThatWereNotScanned: false);

\BeInteractive\TranslationScanner\TranslationScanner::laravel()
    ->getLanguageLines(); // Returns an array of all scanned translations

use BeInteractive\TranslationScanner\Contracts\Scanner;

class MyCustomScanner implements Scanner
{
    /**
     * @return array{group: string, key: string, text: array{string, string}}
     */
    public function getLanguageLines(): array
    {
        return [
            [ 'group' => 'attributes', 'key' => 'name', 'text' => [ 'en' => 'Name' ] ],
        ];
    }
}

\BeInteractive\TranslationScanner\TranslationScanner::laravel()
    ->with(new MyCustomScanner())
    ->store();

// Or only use a custom scanner
\BeInteractive\TranslationScanner\TranslationScanner::with(new MyCustomScanner())
    ->store();
bash
php artisan vendor:publish --provider="BeInteractive\TranslationScanner\TranslationScannerServiceProvider" --tag="translation-scanner-config"
bash
# In this order
php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-migrations"
php artisan vendor:publish --provider="BeInteractive\TranslationScanner\TranslationScannerServiceProvider" --tag="translation-scanner-migrations"
bash
php artisan migrate