PHP code example of cracksalad / i18n

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

    

cracksalad / i18n example snippets


use Cracksalad\I18n\I18n;

$i18n = I18n::load('en');

$i18n->_('Hello world!');       
// -> Hello world!

// format (using sprintf() internally)
$i18n->_f('%d items saved', 42);      
// -> 42 items saved

// ICU MessageFormat
$i18n->_fe('I first published this library on {0, date, short}', 1692982322);
// -> I first published this library on 8/23/23

// singular vs. plural with format
$i18n->_pf('%d item saved', '%d items saved', 42);
// -> 42 items saved
$i18n->_pf('%d item saved', '%d items saved', 1);
// -> 1 item saved