PHP code example of tarektaher / artisan-language

1. Go to this page and download the library: Download tarektaher/artisan-language 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/ */

    

tarektaher / artisan-language example snippets


return [
    'default_language' => 'en', // Default language for synchronization
    'languages' => [ // Supported languages
        'en' => 'English',
        'fr' => 'French',
    ],
    'scan_paths' => [ // Paths to scan for translation keys
        app_path(),
        resource_path('views'),
        resource_path('assets/js'),
    ],
    'scan_pattern' => '/(@lang|__|\$t|\$tc)\s*(\(\s*[\'"])([^$]*)([\'"]+\s*(,[^\)]*)*\))/U', // Regex pattern to detect keys
    'lang_path' => base_path('lang'), // Path to JSON language files
];
bash
php artisan vendor:publish --tag=artisan-language-config
bash
php artisan lg:scan
bash
php artisan lg:scan --lang=fr
bash
php artisan lg:sync {locale}
bash
php artisan lg:sync fr --nomissing
bash
php artisan lg:add {key} {value} {--lang=en}
bash
php artisan lg:remove {key} {--lang=}