PHP code example of thiagocordeiro / laravel-translator

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

    

thiagocordeiro / laravel-translator example snippets


return [
    ...
    'providers' => [
        ...
        Translator\Framework\TranslatorServiceProvider::class,
        ...
    ]
]
-template
blade:
<html>
    @lang('Hello World')
    {{ lang('Hello World') }}
    {{ __('Hello World') }}
</html>

controllers, models, etc.:

    __('Hello World');
    lang('Hello World');

@lang('Welcome, :name', ['Arthur Dent'])

  'output' => base_path('lang'),

use Translator\Framework\LaravelConfigLoader;
use Translator\Infra\LaravelJsonTranslationRepository;

return [
    'languages' => ['pt-br', 'es'],
    'directories' => [
        app_path(),
        resource_path('views'),
    ],
    'functions' => ['lang', '__'],
    'output' => resource_path('lang'),
    'container' => [
        'config_loader' => LaravelConfigLoader::class,
        'translation_repository' => LaravelJsonTranslationRepository::class,
    ],
];
bash
php artisan translator:update
bash
php artisan vendor:publish --provider="Translator\Framework\TranslatorServiceProvider"
bash
php artisan vendor:publish --provider="Translator\Framework\TranslatorServiceProvider"