laravel-money icon indicating copy to clipboard operation
laravel-money copied to clipboard

Custom short difinitions for currencies

Open PostScripton opened this issue 3 years ago • 0 comments

In Russian, we are used to write short definition of ruble like 100 руб., not symbol ₽. So I'd like to add this functionallity on config level and on built-in currency lists for customizing currencies from different countries.

A use-case may look like:

// config/money.php

return [
    // ...

    'primarily_use_custom_definitions' => true,
    'custom_definitions` => [
        'RUB' => 'руб.'
    ],
];
money(1000)->toString(); // "100 ₽"

money(1000)->withCustomDefinition()->toString(); // "100 руб."

money(1000)->settings()->useCustomDefinition(true)->toString(); // "100 руб."

If there's no custom definition in the config file for the currency, then it just ignores and intended symbol is used (₽ / RUB).

You can help me out with the method name in the comments below 😄

PostScripton avatar Dec 27 '21 15:12 PostScripton