PHP code example of skysplit / laravel5-intl-translation

1. Go to this page and download the library: Download skysplit/laravel5-intl-translation 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/ */

    

skysplit / laravel5-intl-translation example snippets


app('translator')->trans($key)
app('translator')->formatMessage($locale, $message, $params)

Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,

Skysplit\Laravel\Translation\TranslationServiceProvider::class,
Skysplit\Laravel\Translation\ValidationServiceProvider::class,

return [
	'placeholder' => 'Hello there, {username}!'
]

{{ trans('custom.placeholder', ['username' => 'Jane']); }}

return [
	'select' => '{gender, select, male{He} female{She} other{It}} has two legs and is {gender}!'
]

{{ trans('custom.select', ['gender' => 'male']); }}
{{ trans('custom.select', ['gender' => 'female']); }}
{{ trans('custom.select', ['gender' => 'penguin']); }}

return [
	'plural' => 'Jon has {n, plural, =0{no apples} one{# apple} other{# apples}}'
]

{{ trans_choice('custom.plural', 0); }}
{{ trans_choice('custom.plural', 1); }}
{{ trans_choice('custom.plural', 2); }}

{{ trans('custom.plural', [3, 'grapes' => 1, 'oranges' => 0]) }}
bash
$ sudo apt-get install php-intl
bash
php artisan vendor:publish --provider="Skysplit\Laravel\Translation\TranslationServiceProvider" --force
bash
php artisan vendor:publish --provider="Skysplit\Laravel\Translation\TranslationServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="Skysplit\Laravel\Translation\TranslationServiceProvider" --force --tag="lang.{locale}[,lang.{other_locale}]"