PHP code example of coderscantina / laravel-translations

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

    

coderscantina / laravel-translations example snippets


use CodersCantina\Translations\Translation;

Translation::create([
    'key' => 'welcome.message',
    'value' => 'Welcome to our application',
    'language_iso' => 'en'
]);

// Using the __ helper
echo __('welcome.message'); // 'Welcome to our application'

// With replacements
echo __('welcome.user', ['name' => 'John']); // 'Welcome, John'

// Specifying language
echo __('welcome.message', [], 'de'); // 'Willkommen in unserer Anwendung'

// Using the trans helper
echo trans('welcome.message');

// Using the facade
use Illuminate\Support\Facades\Lang;
echo Lang::get('welcome.message');
bash
php artisan vendor:publish --provider="CodersCantina\Translations\ServiceProvider" --tag="config"
bash
php artisan migrate