Skip to content

Releases: rmunate/SpellNumber

V 4.2.2

28 Nov 11:28
Compare
Choose a tag to compare

[4.2.2] - 2023-11-28

Changed

  • Zero-width spaces: Characters (\u{AD}, \u{200B}) are removed from the translation outputs.

V 4.2.1

20 Nov 15:05
Compare
Choose a tag to compare

Release Notes

[4.2.0] - 2023-11-20

Added

  • Vietnamese Language Support: Introduced connectors and replacements for the Vietnamese language.

Changed

  • TitleCase to LowerCase: In response to specific language nuances, output is now in lowercase. Developers have the option to modify the output as needed, keeping in mind the use of the callback function.

To swiftly revert to title-formatted output, simply publish the configuration file:

php artisan vendor:publish --provider="Rmunate\\Utilities\\Providers\\SpellNumberProvider" --tag="config"

Then, locate the callback function and adjust the return statement in the configuration file:

return [
  //...
  'callback_output' => function ($data) {

    // Your logic here...

    return \Illuminate\Support\Str::title($data->getWords());
  }, 
]

V 4.2.0

20 Nov 14:59
Compare
Choose a tag to compare

Release Notes

[4.2.0] - 2023-11-20

Added

  • Vietnamese Language Support: Introduced connectors and replacements for the Vietnamese language.

Changed

  • TitleCase to LowerCase: In response to specific language nuances, output is now in lowercase. Developers have the option to modify the output as needed, keeping in mind the use of the callback function.

V 4.1.1

07 Nov 16:29
9c980a2
Compare
Choose a tag to compare

🚀 Release Notes:

🛠️ Adjustment to "Locales" indices for non-preconfigured locales.
🛠️ Adjustment to replacements from the configuration settings.
🚀 Performance improvement.
🛠️ Adjustment of files in the LANG folder.
📜 Creator of accessors for constants.
🧩 Separation of logic into traits.

V 4.1.0

03 Nov 18:37
Compare
Choose a tag to compare

🚀 Milestone Achieved: Proposal #19

📜 New Features:

  • 🆒 Ordinal Text Support: Now you can handle ordinal text with ease.
  • 🗺️ Expanded Locale Freedom: Choose from a wide range of locales beyond the default top 10.
  • ⚙️ Enhanced Global Configuration Options: Enjoy new settings for greater control.
  • 💡 Empowering Constants: Access helpful constants for your code.
  • 🛠️ Macro-Friendly Package: Our package now welcomes macros. You can create and add your desired methods with ease!

This update takes your experience to the next level! 🌟

V 4.0.0

20 Oct 00:27
caa30a6
Compare
Choose a tag to compare

Convert Numbers to Words in Laravel

Easily convert numbers to words in Laravel using this library, which leverages the native PHP INTL extension to perform conversion effortlessly. With this library, you can convert numbers to words in various languages and also obtain the value in currency format according to the selected language. Supported languages include English, Spanish, Portuguese, French, Italian, Romanian, Hindi, Polish and Persian (Farsi).

⚙️ This library is compatible with PHP +8.0 and Laravel versions 8.0 and higher ⚙️

logo-spell-number

Installation

To install the dependency via Composer, execute the following command:

composer require rmunate/spell-number

It's important to ensure that the intl extension is enabled and loaded in the environment.

Usage

📖📖📖 FULL DOCUMENTATION 📖📖📖

After installing the dependency in your project, you can start using it with the following examples:

Languages List Whit Name

Execute the command getLanguages, as output it will give you an associative array with the values of available languages.

use Rmunate\Utilities\SpellNumber;

SpellNumber::getLanguages();

// array:10 [▼ 
//   "de" => "German"
//   "en" => "English"
//   "es" => "Spanish"
//   "fa" => "Farsi"
//   "fr" => "French"
//   "hi" => "Hindi"
//   "it" => "Italian"
//   "pl" => "Polish"
//   "pt" => "Portuguese"
//   "ro" => "Romanian"
// ]

Convert Integers to Words

You can easily convert numbers to words by defining the regional configuration to apply. If you don't define a regional configuration, "en" (English) will be applied by default.

SpellNumber::value(100)->locale('es')->toLetters();
// "Cien"

SpellNumber::value(100)->locale('fa')->toLetters();
// "صد"

SpellNumber::value(100)->locale('en')->toLetters();
// "One Hundred"

SpellNumber::value(100)->locale('hi')->toLetters();
// "एक सौ"

Convert Floating-Point Numbers

If needed, you can pass a floating-point number as an argument to convert it to words.

SpellNumber::value(123456789.12)->locale('es')->toLetters();
// "Ciento Veintitrés Millones Cuatrocientos Cincuenta Y Seis Mil Setecientos Ochenta Y Nueve Con Doce"

SpellNumber::value(123456789.12)->locale('hi')->toLetters();
// "बारह करोड़ चौंतीस लाख छप्पन हज़ार सात सौ नवासी और बारह"

Convert to Currency Format

This method can be useful for invoices, receipts, and similar scenarios. Obtain the supplied value in currency format.

SpellNumber::value(100)->locale('es')->currency('pesos')->toMoney();
// "Cien Pesos"

SpellNumber::value(100.12)->locale('es')->currency('Pesos')->fraction('centavos')->toMoney();
// "Cien Pesos Con Doce Centavos"

SpellNumber::value(100)->locale('fa')->currency('تومان')->toMoney();
// "صد تومان"

SpellNumber::value(100.12)->locale('hi')->currency('रूपये')->fraction('पैसे')->toMoney();
// "एक सौ रूपये और बारह पैसे"

SpellNumber::value(100)->locale('hi')->currency('रूपये')->toMoney();
// "एक सौ रूपये"

SpellNumber::value(100.65)->locale('pl')->currency('złotych')->fraction('groszy')->toMoney();
// "Sto Złotych I Sześćdziesiąt Pięć Groszy"

Creator

License

This project is under the MIT License.

🌟 Support My Projects! 🚀

Become a Sponsor

Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨

If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻

V 3.3.3

13 Oct 01:56
2333c74
Compare
Choose a tag to compare

It is set when the decimal value is 0.
Example:
15.0

SpellNumber::value(15.0)->toLetters()

PR #16
Contributor: https://github.com/gdsrmygdsrjr

V 3.3.2

06 Oct 18:17
e07361c
Compare
Choose a tag to compare

Convert Numbers to Words in Laravel

Easily convert numbers to words in Laravel using this library, which leverages the native PHP INTL extension to perform conversion effortlessly. With this library, you can convert numbers to words in various languages and also obtain the value in currency format according to the selected language. Supported languages include English, Spanish, Portuguese, French, Italian, Romanian, Hindi, Polish and Persian (Farsi).

⚙️ This library is compatible with PHP +8.0 and Laravel versions 8.0 and higher ⚙️

Laravel 8.0+
Laravel 9.0+
Laravel 10.0+

logo-spell-number

📖 DOCUMENTACIÓN EN ESPAÑOL 📖

Table of Contents

Installation

To install the dependency via Composer, execute the following command:

composer require rmunate/spell-number

It's important to ensure that the intl extension is enabled and loaded in the environment.

Usage

After installing the dependency in your project, you can start using it with the following examples:

Knowing Supported Regional Configurations

To obtain the current list of languages with support, execute the following command:

SpellNumber::getAllLocales();
// array [
//    'de', // German
//    'en', // English
//    'es', // Spanish
//    'pt', // Portuguese
//    'fr', // French
//    'it', // Italian
//    'ro', // Romanian
//    'fa', // Farsi
//    'hi', // Hindi
//    'pl', // Polish
// ]

Convert Integers to Words

You can easily convert numbers to words by defining the regional configuration to apply. If you don't define a regional configuration, "en" (English) will be applied by default.

SpellNumber::value(100)->locale('es')->toLetters();
// "Cien"

SpellNumber::value(100)->locale('fa')->toLetters();
// "صد"

SpellNumber::value(100)->locale('en')->toLetters();
// "One Hundred"

SpellNumber::value(100)->locale('hi')->toLetters();
// "एक सौ"

Convert Floating-Point Numbers

If needed, you can pass a floating-point number as an argument to convert it to words.

SpellNumber::value(123456789.12)->locale('es')->toLetters();
// "Ciento Veintitrés Millones Cuatrocientos Cincuenta Y Seis Mil Setecientos Ochenta Y Nueve Con Doce"

SpellNumber::value(123456789.12)->locale('hi')->toLetters();
// "बारह करोड़ चौंतीस लाख छप्पन हज़ार सात सौ नवासी और बारह"

Convert to Currency Format

This method can be useful for invoices, receipts, and similar scenarios. Obtain the supplied value in currency format.

SpellNumber::value(100)->locale('es')->currency('pesos')->toMoney();
// "Cien Pesos"

SpellNumber::value(100.12)->locale('es')->currency('Pesos')->fraction('centavos')->toMoney();
// "Cien Pesos Con Doce Centavos"

SpellNumber::value(100)->locale('fa')->currency('تومان')->toMoney();
// "صد تومان"

SpellNumber::value(100.12)->locale('hi')->currency('रूपये')->fraction('पैसे')->toMoney();
// "एक सौ रूपये और बारह पैसे"

SpellNumber::value(100)->locale('hi')->currency('रूपये')->toMoney();
// "एक सौ रूपये"

SpellNumber::value(100.65)->locale('pl')->currency('złotych')->fraction('groszy')->toMoney();
// "Sto Złotych I Sześćdziesiąt Pięć Groszy"

Other Initializer Methods

To support version 1.X, the following initializer methods are maintained.

// Integer, this method strictly requires an integer value to be sent as an argument.
SpellNumber::integer(100)->locale('es')->toLetters();

// Floating-point numbers, this method strictly requires a string value as an argument.
SpellNumber::float('12345.23')->locale('es')->toLetters();

Creator

Contributors

License

This project is under the MIT License.

🌟 Support My Projects! 🚀

Become a Sponsor

Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨

If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻

V 3.3.1

12 Sep 01:41
Compare
Choose a tag to compare

@ Adjust data return type to work normally on PHP8.0

Convert Numbers to Words in Laravel

Easily convert numbers to words in Laravel using this library, which leverages the native PHP INTL extension to perform conversion effortlessly. With this library, you can convert numbers to words in various languages and also obtain the value in currency format according to the selected language. Supported languages include English, Spanish, Portuguese, French, Italian, Romanian, Hindi, Polish and Persian (Farsi).

⚙️ This library is compatible with PHP +8.0 and Laravel versions 8.0 and higher ⚙️

Laravel 8.0+
Laravel 9.0+
Laravel 10.0+

logo-spell-number

📖 DOCUMENTACIÓN EN ESPAÑOL 📖

Table of Contents

Installation

To install the dependency via Composer, execute the following command:

composer require rmunate/spell-number

It's important to ensure that the intl extension is enabled and loaded in the environment.

Usage

After installing the dependency in your project, you can start using it with the following examples:

Knowing Supported Regional Configurations

To obtain the current list of languages with support, execute the following command:

SpellNumber::getAllLocales();
// array [
//    'de', // German
//    'en', // English
//    'es', // Spanish
//    'pt', // Portuguese
//    'fr', // French
//    'it', // Italian
//    'ro', // Romanian
//    'fa', // Farsi
//    'hi', // Hindi
//    'pl', // Polish
// ]

Convert Integers to Words

You can easily convert numbers to words by defining the regional configuration to apply. If you don't define a regional configuration, "en" (English) will be applied by default.

SpellNumber::value(100)->locale('es')->toLetters();
// "Cien"

SpellNumber::value(100)->locale('fa')->toLetters();
// "صد"

SpellNumber::value(100)->locale('en')->toLetters();
// "One Hundred"

SpellNumber::value(100)->locale('hi')->toLetters();
// "एक सौ"

Convert Floating-Point Numbers

If needed, you can pass a floating-point number as an argument to convert it to words.

SpellNumber::value(123456789.12)->locale('es')->toLetters();
// "Ciento Veintitrés Millones Cuatrocientos Cincuenta Y Seis Mil Setecientos Ochenta Y Nueve Con Doce"

SpellNumber::value(123456789.12)->locale('hi')->toLetters();
// "बारह करोड़ चौंतीस लाख छप्पन हज़ार सात सौ नवासी और बारह"

Convert to Currency Format

This method can be useful for invoices, receipts, and similar scenarios. Obtain the supplied value in currency format.

SpellNumber::value(100)->locale('es')->currency('pesos')->toMoney();
// "Cien Pesos"

SpellNumber::value(100.12)->locale('es')->currency('Pesos')->fraction('centavos')->toMoney();
// "Cien Pesos Con Doce Centavos"

SpellNumber::value(100)->locale('fa')->currency('تومان')->toMoney();
// "صد تومان"

SpellNumber::value(100.12)->locale('hi')->currency('रूपये')->fraction('पैसे')->toMoney();
// "एक सौ रूपये और बारह पैसे"

SpellNumber::value(100)->locale('hi')->currency('रूपये')->toMoney();
// "एक सौ रूपये"

SpellNumber::value(100.65)->locale('pl')->currency('złotych')->fraction('groszy')->toMoney();
// "Sto Złotych I Sześćdziesiąt Pięć Groszy"

Other Initializer Methods

To support version 1.X, the following initializer methods are maintained.

// Integer, this method strictly requires an integer value to be sent as an argument.
SpellNumber::integer(100)->locale('es')->toLetters();

// Floating-point numbers, this method strictly requires a string value as an argument.
SpellNumber::float('12345.23')->locale('es')->toLetters();

Creator

Contributors

License

This project is under the MIT License.

🌟 Support My Projects! 🚀

Become a Sponsor

Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨

If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻

V 3.3.0

11 Sep 17:35
Compare
Choose a tag to compare

Convert Numbers to Words in Laravel

Easily convert numbers to words in Laravel using this library, which leverages the native PHP INTL extension to perform conversion effortlessly. With this library, you can convert numbers to words in various languages and also obtain the value in currency format according to the selected language. Supported languages include English, Spanish, Portuguese, French, Italian, Romanian, Hindi, Polish and Persian (Farsi).

⚙️ This library is compatible with Laravel versions 8.0 and higher ⚙️

Laravel 8.0+
Laravel 9.0+
Laravel 10.0+

logo-spell-number

📖 DOCUMENTACIÓN EN ESPAÑOL 📖

Table of Contents

Installation

To install the dependency via Composer, execute the following command:

composer require rmunate/spell-number

It's important to ensure that the intl extension is enabled and loaded in the environment.

Usage

After installing the dependency in your project, you can start using it with the following examples:

Knowing Supported Regional Configurations

To obtain the current list of languages with support, execute the following command:

SpellNumber::getAllLocales();
// array [
//    'de', // German from Germany
//    'en', // English from the United States
//    'es', // Spanish from Spain
//    'pt', // Portuguese from Portugal
//    'fr', // French from France
//    'it', // Italian from Italy
//    'ro', // Romanian from Romania
//    'fa', // Farsi from Iran
//    'hi', // Hindi from India
//    'pl', // Polish from Poland
// ]

Convert Integers to Words

You can easily convert numbers to words by defining the regional configuration to apply. If you don't define a regional configuration, "en" (English) will be applied by default.

SpellNumber::value(100)->locale('es')->toLetters();
// "Cien"

SpellNumber::value(100)->locale('fa')->toLetters();
// "صد"

SpellNumber::value(100)->locale('en')->toLetters();
// "One Hundred"

SpellNumber::value(100)->locale('hi')->toLetters();
// "एक सौ"

Convert Floating-Point Numbers

If needed, you can pass a floating-point number as an argument to convert it to words.

SpellNumber::value(123456789.12)->locale('es')->toLetters();
// "Ciento Veintitrés Millones Cuatrocientos Cincuenta Y Seis Mil Setecientos Ochenta Y Nueve Con Doce"

SpellNumber::value(123456789.12)->locale('hi')->toLetters();
// "बारह करोड़ चौंतीस लाख छप्पन हज़ार सात सौ नवासी और बारह"

Convert to Currency Format

This method can be useful for invoices, receipts, and similar scenarios. Obtain the supplied value in currency format.

SpellNumber::value(100)->locale('es')->currency('pesos')->toMoney();
// "Cien Pesos"

SpellNumber::value(100.12)->locale('es')->currency('Pesos')->fraction('centavos')->toMoney();
// "Cien Pesos Con Doce Centavos"

SpellNumber::value(100)->locale('fa')->currency('تومان')->toMoney();
// "صد تومان"

SpellNumber::value(100.12)->locale('hi')->currency('रूपये')->fraction('पैसे')->toMoney();
// "एक सौ रूपये और बारह पैसे"

SpellNumber::value(100)->locale('hi')->currency('रूपये')->toMoney();
// "एक सौ रूपये"

SpellNumber::value(100.65)->locale('pl')->currency('złotych')->fraction('groszy')->toMoney();
// "Sto Złotych I Sześćdziesiąt Pięć Groszy"

Other Initializer Methods

To support version 1.X, the following initializer methods are maintained.

// Integer, this method strictly requires an integer value to be sent as an argument.
SpellNumber::integer(100)->locale('es')->toLetters();

// Floating-point numbers, this method strictly requires a string value as an argument.
SpellNumber::float('12345.23')->locale('es')->toLetters();

Creator

Contributors

License

This project is under the MIT License.

🌟 Support My Projects! 🚀

Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨

If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻