PHP code example of icanboogie / bind-cldr

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

    

icanboogie / bind-cldr example snippets




/** @var ICanBoogie\Application $app */

use ICanBoogie\CLDR\Repository;
use ICanBoogie\Binding\CLDR\CurrentLocale;

# Getting the CLDR
$cldr = $app->service_for_class(Repository::class);
echo $cldr->locale_for('fr')->format_number("1234567.89"); // 1 234 567,89

# Getting the current locale, defaulting to 'en' locale
$current_locale = $app->service_for_class(CurrentLocale::class);
echo $current_locale->get()->id->value             // en

# Change the current locale to 'fr'
$current_locale->set('fr')
echo $current_locale->get()->id->value             // fr