PHP code example of italix / i18n

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

    

italix / i18n example snippets


$t = translator(__DIR__ . '/lang', 'it-IT', 'en');

$t->get('admin.users.title');                  // 'Utenti'
$t->get('greeting', ['name' => 'Anna']);       // 'Ciao, Anna!'
$t->choice('files.count', 3);                  // '3 file'

$f = formatter('it-IT', 'Europe/Rome');
$f->currency(1234.5, 'EUR');                   // '1.234,50 €'
$f->percent(0.075);                            // '7,5%'
$f->date_time($when, 'full', 'short');         // 'giovedì 6 agosto 2026 09:06'

'files' => '{n, plural, =0 {nessun file} one {# file} other {# file}}'

$f->number(1234567.891);      // it: 1.234.567,891   en: 1,234,567.891
$f->currency(1234.5, 'EUR');  // it: 1.234,50 €      en: €1,234.50
$f->percent(0.075);           // 7,5%  — see below
$f->ordinal(3);               // it: 3º   en: 3rd
$f->spell(42);                // quarantadue
$f->bytes(1536000);           // 1,5 MiB
$f->date_time($when, 'full', 'short');
$f->pattern($when, 'd MMMM y');

$parts = $f->relative_parts($then);
// ['unit_c' => 'day', 'count_n' => 3, 'is_past' => true, 'seconds_n' => -259200]

$t->choice('time.past.' . $parts['unit_c'], $parts['count_n']);
// 'time.past.day' => '{n, plural, one {# giorno fa} other {# giorni fa}}'

Locale::normalise('it_IT');                    // 'it-IT'
Locale::chain('de-AT', 'en');                  // ['de-AT', 'de', 'en']
Locale::best_of('it', ['en', 'it-CH']);        // 'it-CH'
Locale::from_header('fr-CH, fr;q=0.9, en;q=0.8');

H::e($t->get('k', $params))     // safe, and destroys any markup the message carries
H::raw($t->get('k', $params))   // keeps the markup, and prints the parameter unencoded

// lang/it/messages.php
'subtitle' => 'Order for <strong>{customer}</strong>',

<?= $t->e('orders.subtitle', ['customer' => $row['customer_name']]) 

$body = T::for_locale($recipient_lang_c, fn () => $view->render('mail/deposit_requested'));