PHP code example of bakame / laravel-intl-formatter
1. Go to this page and download the library: Download bakame/laravel-intl-formatter 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/ */
bakame / laravel-intl-formatter example snippets
echo view($templatePath, ['country' => 'FR', 'locale' => 'NL'])->render();
// country name: Frankrijk
echo view($templatePath, ['currency' => 'JPY', 'locale' => 'PT'])->render();
// currency name: Iene japonês
echo view($templatePath, ['currency' => 'JPY', 'locale' => 'PT'])->render();
// currency symbol: JP¥
echo view($templatePath, ['language' => 'it', 'locale' => 'nl'])->render();
// language name: Italiaans
echo view($templatePath, ['data' => 'sw', 'locale' => 'nl'])->render();
// locale name: Swahili
echo view($templatePath, ['timezone' => 'Asia/Tokyo', 'locale' => 'es'])->render();
// timezone name: hora de Japón (Tokio)
$content = view($templatePath, ['country' => 'CD', 'locale' => 'es'])->render();
echo $content, PHP_EOL; // country timezones: Africa/Kinshasa, Africa/Lubumbashi
$templateData = [
'amount' => 100.356,
'currency' => 'USD',
'locale' => 'ES',
'attrs' => [
'fraction_digit' => 1,
'rounding_mode' => 'floor',
]
];
echo view($templatePath, $templateData)->render();
// format currency: 100,3 US$
$templateData = [
'number' => 100.356,
'locale' => 'nl',
'style' => 'spellout',
'type' => 'double',
'attrs' => [
'fraction_digit' => 1,
'rounding_mode' => 'floor',
]
];
echo view($templatePath, $templateData)->render();
// format number: honderd komma drie
$templateData = [
'date' => 'yesterday',
'dateFormat' => 'full',
'timeFormat' => 'full',
'pattern' => '' ,
'timezone' => 'Africa/Lubumbashi',
'calendar' => 'gregorian' ,
'locale' => 'sw',
];
echo view($templatePath, $templateData)->render();
// format datetime: Alhamisi, 2 Juni 2022 00:00:00 Saa za Afrika ya Kati
$templateData = [
'date' => 'yesterday',
'dateFormat' => 'long',
'pattern' => '' ,
'timezone' => 'Africa/Lubumbashi',
'calendar' => 'gregorian' ,
'locale' => 'sw',
];
echo view($templatePath, $templateData)->render();
// format date: 2 Juni 2022
$templateData = [
'date' => 'yesterday',
'dateFormat' => 'full',
'pattern' => '' ,
'timezone' => 'Africa/Lubumbashi',
'calendar' => 'gregorian' ,
'locale' => 'sw',
];
echo view($templatePath, $templateData)->render();
// format time: 00:00:00 Saa za Afrika ya Kati
echo format_datetime('2019-08-07 23:39:12', 'fr', null, medium', 'medium', '', 'gregorian', 'fr');
echo format_datetime(date: '2019-08-07 23:39:12', locale: 'fr');
bash
php artisan vendor:publish --provider="Bakame\Laravel\Intl" --tag=config