PHP code example of alright / laravel-icu

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

    

alright / laravel-icu example snippets


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

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

Alright\Laravel\Translation\TranslationServiceProvider::class,
Alright\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="Alright\Laravel\Translation\TranslationServiceProvider" --force
bash
php artisan vendor:publish --provider="Alright\Laravel\Translation\TranslationServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="Alright\Laravel\Translation\TranslationServiceProvider" --force --tag="lang.{locale}[,lang.{other_locale}]"