PHP code example of nurbekjummayev / laravel-number-words

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

    

nurbekjummayev / laravel-number-words example snippets


'default_locale' => env('MULTILANG_LOCALE', 'uz'),

use MultiLangFormatter\Facades\ML;

// Uzbek (default)
echo ML::number()->toWords(1234567);
// Output: "Bir million ikki yuz o'ttiz to'rt ming besh yuz oltmish yetti"

// English
echo ML::number()->locale('en')->toWords(1234567);
// Output: "One million two hundred thirty-four thousand five hundred sixty-seven"

// Russian
echo ML::number()->locale('ru')->toWords(1234567);
// Output: "Один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь"

// Default locale
echo ml_number(12345);
// Output: "O'n ikki ming uch yuz qirq besh"

// Specific locale
echo ml_number(12345, 'en');
// Output: "Twelve thousand three hundred forty-five"

// With options
echo ml_number(1234.56, 'uz', ['decimals' => true, 'capitalize' => true]);
// Output: "Bir ming ikki yuz o'ttiz to'rt, 56"

use MultiLangFormatter\Facades\ML;

// Uzbek
echo ML::number()->toCurrency(1500.50);
// Output: "Bir ming besh yuz so'm 50 tiyin"

// English
echo ML::number()->locale('en')->toCurrency(1500.50);
// Output: "One thousand five hundred dollar 50 cent"

// Custom currency
echo ML::number()->toCurrency(2000, 'EUR');
// Output: "Ikki ming EUR"

// Using helper
echo ml_currency(1500.50);
// Output: "Bir ming besh yuz so'm 50 tiyin"

use MultiLangFormatter\Facades\ML;

// Uzbek
echo ML::number()->toOrdinal(1);  // "birinchi"
echo ML::number()->toOrdinal(2);  // "ikkinchi"
echo ML::number()->toOrdinal(3);  // "uchinchi"

// English
echo ML::number()->locale('en')->toOrdinal(1);  // "first"
echo ML::number()->locale('en')->toOrdinal(2);  // "second"
echo ML::number()->locale('en')->toOrdinal(3);  // "third"

// Using helper
echo ml_ordinal(1);        // "birinchi"
echo ml_ordinal(21, 'en'); // "twenty-first"

use MultiLangFormatter\Facades\ML;

// Uzbek
echo ML::date()->format('2024-03-15', 'full');
// Output: "2024-yil 15-Mart, Juma"

// English
echo ML::date()->locale('en')->format('2024-03-15', 'full');
// Output: "Friday, March 15, 2024"

// Russian
echo ML::date()->locale('ru')->format('2024-03-15', 'full');
// Output: "Пятница, 15 Март 2024"

// Using helper
echo ml_date('2024-03-15', 'full');
// Output: "2024-yil 15-Mart, Juma"

echo ml_date('2024-03-15', 'short', 'en');
// Output: "March 15"

use MultiLangFormatter\Facades\ML;

// Uzbek
echo ML::date()->relative('2024-03-14');
// Output: "1 kun oldin"

// English
echo ML::date()->locale('en')->relative('2024-03-14');
// Output: "1 day ago"

// Russian
echo ML::date()->locale('ru')->relative('2024-03-14');
// Output: "1 день назад"

// Using helper
echo ml_date_relative('2024-03-14');
// Output: "1 kun oldin"


return [
    'words' => [
        1000 => 'bin',
        100 => 'yüz',
        // ... more numbers
    ],
    'scales' => [
        4 => 'milyar',
        3 => 'milyon',
        2 => 'bin',
    ],
    'ordinals' => [
        1 => 'birinci',
        2 => 'ikinci',
        // ... more
    ],
    'default_currency' => 'lira',
    'plural_rule' => 'none',
];


return [
    'months' => [
        1 => 'Ocak',
        2 => 'Şubat',
        // ... more months
    ],
    'weekdays' => [
        0 => 'Pazar',
        1 => 'Pazartesi',
        // ... more days
    ],
    // ... other date settings
];

echo ml_number(1234, 'tr');
// Output: "bin iki yüz otuz dört"
bash
php artisan vendor:publish --tag=multilang-config
bash
php artisan vendor:publish --tag=multilang-translations