PHP code example of iqomp / locale

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

    

iqomp / locale example snippets



// dududu.php

return [
    'Thankyou' => 'Thank you!',
    'Hi name'  => 'Hi {name}!',
    'x item'   => '{qty, number} {qty, plural, =0{item}=1{item}other{items}}'
];


use Iqomp\Locale\Locale;

// optional
Locale::setLanguage('en-US', 'en-UK', 'en');

$res = Locale::translate('Thankyou');
$res = Locale::translate('Hi name', ['name'=>'Iqbal']);
$res = Locale::translate('x item', ['qty'=>12], 'dududu');

$object = [
    'user' => 1,
    'greeting' => Locale::encode('Hello name', [
        'title' => 'Mr',
        'name'  => '$user.name.last'
    ])
];

Model::create($object);

return [
    'formats' => [
        'greeting' => [
            'user' => stdModel,// ...
            'greeting' => [
                'type' => 'locale'
            ]
        ]
    ]
];

composer lint

[locale/main/path]/
    [locale-NAME]/
        [domain].php
    en-US/
        gender.php
        ...
    id-ID/
        gender.php
        ...