PHP code example of xdg / locale

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

    

xdg / locale example snippets


use Xdg\Locale\Locale;

// from a POSIX locale identifier
$locale = Locale::of('ca_ES@valencia');
// from an IETF (BCP47) language tag
$locale = Locale::of('zh-Hans-CN');
// On Windows, windows-specific locale identifiers are accepted
$locale = Locale::of('French_France.1252');

use Xdg\Locale\Locale;

$locale = Locale::of('fr_FR.UTF-8')
$locale->matches('fr'); // => true
$locale->matches('fr_BE'); // => false

use Xdg\Locale\Locale;

$locale = Locale::of('fr_FR.UTF-8')
$locale->select(['fr_CA', 'fr_BE', 'fr']); // => 'fr'