PHP code example of clusteramaryllis / gettext

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

    

clusteramaryllis / gettext example snippets


'providers' => [

    // ...

    Clusteramaryllis\Gettext\GettextServiceProvider::class,

]

'aliases' => [

    // ...

    'Gettext' => Clusteramaryllis\Gettext\Facades\Gettext::class,

]

languages => [

    // ...,

    'sv' => [
        'locale' => 'sv_SE',
        'encoding' => 'utf-8',
        'plural_forms' => "nplurals=2; plural=(n != 1);",
    ]      
]

Route::get('/', function() {

    Gettext::bindTextDomain('messages', base_path('resources/locale'));
    Gettext::textDomain('messages');

    Gettext::setLocale(LC_ALL, 'sv_SE.utf-8');

    return view('welcome');
});
bash
php artisan vendor:publish
bash
php artisan gettext:create --sources="app/Http/Controllers, resources/views" --destination="resources/locale" --locale="en_US" 
html
<!-- resources\views\welcome.blade.php -->
{!! __('Welcome to main page') !!}